Skip to content

Commit 3d5d582

Browse files
committed
Add optional-packages test
1 parent 66a94a8 commit 3d5d582

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

cabal-install/tests/IntegrationTests2/ProjectConfig/ParsecTests.hs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ parserTests :: [TestTree]
2323
parserTests = [
2424
-- testCase "read with legacy parser" testLegacyRead
2525
testCase "read packages" testPackages
26+
, testCase "read optional-packages" testOptionalPackages
2627
]
2728

2829
-- Currently I compare the results of legacy parser with the new parser
@@ -54,8 +55,13 @@ testPackages = do
5455
-- Note that I currently also run the legacy parser to make sure my expected values
5556
-- do not differ from the non-Parsec implementation, this will be removed in the future
5657
(config, legacy) <- readConfigDefault "packages"
57-
assertConfig expected config (projectPackages . condTreeData)
58-
assertConfig expected legacy (projectPackages . condTreeData)
58+
assertConfig expected config legacy (projectPackages . condTreeData)
59+
60+
testOptionalPackages :: Assertion
61+
testOptionalPackages = do
62+
let expected = [".", "packages/packages.cabal"]
63+
(config, legacy) <- readConfigDefault "optional-packages"
64+
assertConfig expected config legacy (projectPackagesOptional . condTreeData)
5965

6066
readConfigDefault :: FilePath -> IO (ProjectConfigSkeleton, ProjectConfigSkeleton)
6167
readConfigDefault rootFp = readConfig rootFp "cabal.project"
@@ -79,10 +85,18 @@ readConfig rootFp projectFileName = do
7985
readProjectFileSkeletonLegacy verbosity httpTransport distDirLayout extensionName extensionDescription
8086
return (parsec, legacy)
8187

82-
assertConfig :: (Eq a, Show a) => a -> ProjectConfigSkeleton -> (ProjectConfigSkeleton -> a) -> IO ()
83-
assertConfig expected config access = expected @=? actual
88+
assertConfig' :: (Eq a, Show a) => a -> ProjectConfigSkeleton -> (ProjectConfigSkeleton -> a) -> IO ()
89+
assertConfig' expected config access = expected @=? actual
90+
where
91+
actual = access config
92+
93+
assertConfig :: (Eq a, Show a) => a -> ProjectConfigSkeleton -> ProjectConfigSkeleton -> (ProjectConfigSkeleton -> a) -> IO ()
94+
assertConfig expected config configLegacy access = do
95+
expected @=? actualLegacy
96+
expected @=? actual
8497
where
8598
actual = access config
99+
actualLegacy = access configLegacy
86100

87101
-- | Test Utilities
88102
emptyProjectConfig :: ProjectConfig
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
optional-packages: . packages/packages.cabal

cabal-install/tests/IntegrationTests2/ProjectConfig/files/packages/packages.project

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)