Skip to content

Commit

Permalink
Add solver unit tests for sub-library dependencies (issue #6039).
Browse files Browse the repository at this point in the history
  • Loading branch information
grayjay committed Nov 21, 2019
1 parent 94b03b6 commit d22f35a
Showing 1 changed file with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ tests = [
, runTest $ mkTest dbBJ7 "bj7" ["A"] (solverSuccess [("A", 1), ("B", 1), ("C", 1)])
, runTest $ indep $ mkTest dbBJ8 "bj8" ["A", "B"] (solverSuccess [("A", 1), ("B", 1), ("C", 1)])
]
, testGroup "library dependencies" [
, testGroup "main library dependencies" [
let db = [Right $ exAvNoLibrary "A" 1 `withExe` exExe "exe" []]
in runTest $ mkTest db "install build target without a library" ["A"] $
solverSuccess [("A", 1)]
Expand All @@ -298,6 +298,62 @@ tests = [
in runTest $ mkTest db "choose version of build-depends dependency that has a library" ["A"] $
solverSuccess [("A", 1), ("B", 1)]
]
, testGroup "sub-library dependencies" [
let db = [ Right $ exAv "A" 1 [ExSubLibAny "B" "sub-lib"]
, Right $ exAv "B" 1 [] ]
in runTest $
mkTest db "reject package that is missing required sub-library" ["A"] $
solverFailure $ isInfixOf $
"rejecting: B-1.0.0 (does not contain library 'sub-lib', which is required by A)"

, let db = [ Right $ exAv "A" 1 [ExSubLibAny "B" "sub-lib"]
, Right $ exAvNoLibrary "B" 1 `withSubLibrary` exSubLib "sub-lib" [] ]
in runTest $
mkTest db "reject package with private but required sub-library" ["A"] $
solverFailure $ isInfixOf $
"rejecting: B-1.0.0 (library 'sub-lib' is private, but it is required by A)"

, let db = [ Right $ exAv "A" 1 [ExSubLibAny "B" "sub-lib"]
, Right $ exAvNoLibrary "B" 1
`withSubLibrary` exSubLib "sub-lib" [ExFlagged "make-lib-private" (dependencies []) publicDependencies] ]
in runTest $ constraints [ExFlagConstraint (ScopeAnyQualifier "B") "make-lib-private" True] $
mkTest db "reject package with sub-library made private by flag constraint" ["A"] $
solverFailure $ isInfixOf $
"rejecting: B-1.0.0 (library 'sub-lib' is private, but it is required by A)"

, let db = [ Right $ exAv "A" 1 [ExSubLibAny "B" "sub-lib"]
, Right $ exAvNoLibrary "B" 1
`withSubLibrary` exSubLib "sub-lib" [ExFlagged "make-lib-private" (dependencies []) publicDependencies] ]
in runTest $
mkTest db "treat sub-library as visible even though flag choice could make it private" ["A"] $
solverSuccess [("A", 1), ("B", 1)]

, let db = [ Right $ exAv "A" 1 [ExAny "B"]
, Right $ exAv "B" 1 [] `withSubLibrary` exSubLib "sub-lib" []
, Right $ exAv "C" 1 [ExSubLibAny "B" "sub-lib"] ]
goals :: [ExampleVar]
goals = [
P QualNone "A"
, P QualNone "B"
, P QualNone "C"
]
in runTest $ goalOrder goals $
mkTest db "reject package that requires a private sub-library" ["A", "C"] $
solverFailure $ isInfixOf $
"rejecting: C-1.0.0 (requires library 'sub-lib' from B, but the component is private)"

, let db = [ Right $ exAv "A" 1 [ExSubLibAny "B" "sub-lib-v1"]
, Right $ exAv "B" 2 [] `withSubLibrary` ExSubLib "sub-lib-v2" publicDependencies
, Right $ exAv "B" 1 [] `withSubLibrary` ExSubLib "sub-lib-v1" publicDependencies ]
in runTest $ mkTest db "choose version of package containing correct sub-library" ["A"] $
solverSuccess [("A", 1), ("B", 1)]

, let db = [ Right $ exAv "A" 1 [ExSubLibAny "B" "sub-lib"]
, Right $ exAv "B" 2 [] `withSubLibrary` ExSubLib "sub-lib" (dependencies [])
, Right $ exAv "B" 1 [] `withSubLibrary` ExSubLib "sub-lib" publicDependencies ]
in runTest $ mkTest db "choose version of package with public sub-library" ["A"] $
solverSuccess [("A", 1), ("B", 1)]
]
-- build-tool-depends dependencies
, testGroup "build-tool-depends" [
runTest $ mkTest dbBuildTools "simple exe dependency" ["A"] (solverSuccess [("A", 1), ("bt-pkg", 2)])
Expand Down

0 comments on commit d22f35a

Please sign in to comment.