@@ -23,6 +23,7 @@ parserTests :: [TestTree]
23
23
parserTests = [
24
24
-- testCase "read with legacy parser" testLegacyRead
25
25
testCase " read packages" testPackages
26
+ , testCase " read optional-packages" testOptionalPackages
26
27
]
27
28
28
29
-- Currently I compare the results of legacy parser with the new parser
@@ -54,8 +55,13 @@ testPackages = do
54
55
-- Note that I currently also run the legacy parser to make sure my expected values
55
56
-- do not differ from the non-Parsec implementation, this will be removed in the future
56
57
(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)
59
65
60
66
readConfigDefault :: FilePath -> IO (ProjectConfigSkeleton , ProjectConfigSkeleton )
61
67
readConfigDefault rootFp = readConfig rootFp " cabal.project"
@@ -79,10 +85,18 @@ readConfig rootFp projectFileName = do
79
85
readProjectFileSkeletonLegacy verbosity httpTransport distDirLayout extensionName extensionDescription
80
86
return (parsec, legacy)
81
87
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
84
97
where
85
98
actual = access config
99
+ actualLegacy = access configLegacy
86
100
87
101
-- | Test Utilities
88
102
emptyProjectConfig :: ProjectConfig
0 commit comments