Commit d70e6f13 authored by kristenk's avatar kristenk
Browse files

Refactor function to enable all tests in solver DSL.

parent c0028c4c
......@@ -55,15 +55,15 @@ tests = [
, runTest $ indep $ mkTest db18 "linkFlags3" ["A", "B"] (solverSuccess [("A", 1), ("B", 1), ("C", 1), ("D", 1), ("D", 2), ("F", 1)])
]
, testGroup "Stanzas" [
runTest $ mkTestEnableAllTests db5 "simpleTest1" ["C"] (solverSuccess [("A", 2), ("C", 1)])
, runTest $ mkTestEnableAllTests db5 "simpleTest2" ["D"] anySolverFailure
, runTest $ mkTestEnableAllTests db5 "simpleTest3" ["E"] (solverSuccess [("A", 1), ("E", 1)])
, runTest $ mkTestEnableAllTests db5 "simpleTest4" ["F"] anySolverFailure -- TODO
, runTest $ mkTestEnableAllTests db5 "simpleTest5" ["G"] (solverSuccess [("A", 2), ("G", 1)])
, runTest $ mkTestEnableAllTests db5 "simpleTest6" ["E", "G"] anySolverFailure
, runTest $ indep $ mkTestEnableAllTests db5 "simpleTest7" ["E", "G"] (solverSuccess [("A", 1), ("A", 2), ("E", 1), ("G", 1)])
, runTest $ mkTestEnableAllTests db6 "depsWithTests1" ["C"] (solverSuccess [("A", 1), ("B", 1), ("C", 1)])
, runTest $ indep $ mkTestEnableAllTests db6 "depsWithTests2" ["C", "D"] (solverSuccess [("A", 1), ("B", 1), ("C", 1), ("D", 1)])
runTest $ enableAllTests $ mkTest db5 "simpleTest1" ["C"] (solverSuccess [("A", 2), ("C", 1)])
, runTest $ enableAllTests $ mkTest db5 "simpleTest2" ["D"] anySolverFailure
, runTest $ enableAllTests $ mkTest db5 "simpleTest3" ["E"] (solverSuccess [("A", 1), ("E", 1)])
, runTest $ enableAllTests $ mkTest db5 "simpleTest4" ["F"] anySolverFailure -- TODO
, runTest $ enableAllTests $ mkTest db5 "simpleTest5" ["G"] (solverSuccess [("A", 2), ("G", 1)])
, runTest $ enableAllTests $ mkTest db5 "simpleTest6" ["E", "G"] anySolverFailure
, runTest $ indep $ enableAllTests $ mkTest db5 "simpleTest7" ["E", "G"] (solverSuccess [("A", 1), ("A", 2), ("E", 1), ("G", 1)])
, runTest $ enableAllTests $ mkTest db6 "depsWithTests1" ["C"] (solverSuccess [("A", 1), ("B", 1), ("C", 1)])
, runTest $ indep $ enableAllTests $ mkTest db6 "depsWithTests2" ["C", "D"] (solverSuccess [("A", 1), ("B", 1), ("C", 1), ("D", 1)])
]
, testGroup "Setup dependencies" [
runTest $ mkTest db7 "setupDeps1" ["B"] (solverSuccess [("A", 2), ("B", 1)])
......@@ -139,7 +139,7 @@ tests = [
testBuildable "avoid building component with unknown dependency" (ExAny "unknown")
, testBuildable "avoid building component with unknown extension" (ExExt (UnknownExtension "unknown"))
, testBuildable "avoid building component with unknown language" (ExLang (UnknownLanguage "unknown"))
, runTest $ mkTestEnableAllTests dbBuildable1 "choose flags that set buildable to false" ["pkg"] (solverSuccess [("flag1-false", 1), ("flag2-true", 1), ("pkg", 1)])
, runTest $ enableAllTests $ mkTest dbBuildable1 "choose flags that set buildable to false" ["pkg"] (solverSuccess [("flag1-false", 1), ("flag2-true", 1), ("pkg", 1)])
, runTest $ mkTest dbBuildable2 "choose version that sets buildable to false" ["A"] (solverSuccess [("A", 1), ("B", 2)])
]
, testGroup "Pkg-config dependencies" [
......@@ -207,6 +207,9 @@ goalOrder order test = test { testGoalOrder = Just order }
preferences :: [ExPreference] -> SolverTest -> SolverTest
preferences prefs test = test { testSoftConstraints = prefs }
enableAllTests :: SolverTest -> SolverTest
enableAllTests test = test { testEnableAllTests = EnableAllTests True }
data GoalOrder = FixedGoalOrder | DefaultGoalOrder
{-------------------------------------------------------------------------------
......@@ -267,15 +270,7 @@ mkTest :: ExampleDb
-> [String]
-> SolverResult
-> SolverTest
mkTest = mkTestAllOptions (EnableAllTests False) Nothing Nothing []
-- | Makes a solver test case with all packages' tests enabled.
mkTestEnableAllTests :: ExampleDb
-> String
-> [String]
-> SolverResult
-> SolverTest
mkTestEnableAllTests = mkTestAllOptions (EnableAllTests True) Nothing Nothing []
mkTest = mkTestExtLangPC Nothing Nothing []
mkTestExts :: [Extension]
-> ExampleDb
......@@ -309,19 +304,7 @@ mkTestExtLangPC :: Maybe [Extension]
-> [String]
-> SolverResult
-> SolverTest
mkTestExtLangPC = mkTestAllOptions (EnableAllTests False)
mkTestAllOptions :: EnableAllTests
-> Maybe [Extension]
-> Maybe [Language]
-> [(String, String)]
-> ExampleDb
-> String
-> [String]
-> SolverResult
-> SolverTest
mkTestAllOptions enableTests exts langs pkgConfigDb db label targets result =
SolverTest {
mkTestExtLangPC exts langs pkgConfigDb db label targets result = SolverTest {
testLabel = label
, testTargets = targets
, testResult = result
......@@ -332,7 +315,7 @@ mkTestAllOptions enableTests exts langs pkgConfigDb db label targets result =
, testSupportedExts = exts
, testSupportedLangs = langs
, testPkgConfigDb = pkgConfigDbFromList pkgConfigDb
, testEnableAllTests = enableTests
, testEnableAllTests = EnableAllTests False
}
runTest :: SolverTest -> TF.TestTree
......@@ -716,7 +699,7 @@ db16 = [
testIndepGoals2 :: String -> SolverTest
testIndepGoals2 name =
goalOrder goals $ indep $
mkTestEnableAllTests db name ["A", "B"] $
enableAllTests $ mkTest db name ["A", "B"] $
solverSuccess [("A", 1), ("B", 1), ("C", 1), ("D", 1)]
where
db :: ExampleDb
......@@ -841,7 +824,7 @@ testIndepGoals3 name =
testIndepGoals4 :: String -> SolverTest
testIndepGoals4 name =
goalOrder goals $ indep $
mkTestEnableAllTests db name ["A", "B", "C"] $
enableAllTests $ mkTest db name ["A", "B", "C"] $
solverSuccess [("A",1), ("B",1), ("C",1), ("D",1), ("E",1), ("E",2)]
where
db :: ExampleDb
......@@ -996,9 +979,8 @@ dbLangs1 = [
-- depend on "false-dep".
testBuildable :: String -> ExampleDependency -> TestTree
testBuildable testName unavailableDep =
runTest $
mkTestAllOptions (EnableAllTests True)
(Just []) (Just []) [] db testName ["pkg"] expected
runTest $ enableAllTests $
mkTestExtLangPC (Just []) (Just []) [] db testName ["pkg"] expected
where
expected = solverSuccess [("false-dep", 1), ("pkg", 1)]
db = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment