From 573c15d2b449d9cb72c2c0a6728f3b89ba2fd0cb Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Fri, 24 Nov 2023 12:31:41 +0000 Subject: [PATCH] testsuite: Add some tests for setup component scope interacts with stanza flags These tests check how the setup qualified scope interacts with the stanza flags (specified on the top-level and with the any qualifier) --- .../Distribution/Solver/Modular/Solver.hs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs index ee64ec115c7..d32bc85dc15 100644 --- a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs +++ b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs @@ -182,6 +182,8 @@ tests = , runTest $ mkTest db9 "setupDeps7" ["F", "G"] (solverSuccess [("A", 1), ("B", 1), ("B", 2), ("C", 1), ("D", 1), ("E", 1), ("E", 2), ("F", 1), ("G", 1)]) , runTest $ mkTest db10 "setupDeps8" ["C"] (solverSuccess [("C", 1)]) , runTest $ indep $ mkTest dbSetupDeps "setupDeps9" ["A", "B"] (solverSuccess [("A", 1), ("B", 1), ("C", 1), ("D", 1), ("D", 2)]) + , runTest $ setupStanzaTest1 + , runTest $ setupStanzaTest2 ] , testGroup "Base shim" @@ -2555,6 +2557,32 @@ dbIssue3775 = , Right $ exAv "B" 2 [ExAny "A", ExAny "warp"] ] +-- A database where the setup depends on something which has a test stanza, does the +-- test stanza get enabled? +dbSetupStanza :: ExampleDb +dbSetupStanza = + [ Right $ + exAv "A" 1 [] + `withSetupDeps` [ExAny "B"] + , Right $ + exAv "B" 1 [] + `withTest` exTest "test" [ExAny "C"] + ] + +-- With the "top-level" qualifier syntax +setupStanzaTest1 :: SolverTest +setupStanzaTest1 = constraints [ExStanzaConstraint (scopeToplevel "B") [TestStanzas]] $ mkTest dbSetupStanza "setupStanzaTest1" ["A"] (solverSuccess [("A", 1), ("B", 1)]) + +-- With the "any" qualifier syntax +setupStanzaTest2 :: SolverTest +setupStanzaTest2 = + constraints [ExStanzaConstraint (ScopeAnyQualifier "B") [TestStanzas]] $ + mkTest + dbSetupStanza + "setupStanzaTest2" + ["A"] + (solverFailure ("unknown package: A:setup.C (dependency of A:setup.B *test)" `isInfixOf`)) + -- | Returns true if the second list contains all elements of the first list, in -- order. containsInOrder :: Eq a => [a] -> [a] -> Bool