@@ -14,6 +14,10 @@ import Distribution.Client.DistDirLayout
1414import Distribution.Client.ProjectConfig
1515import Distribution.Client.RebuildMonad (runRebuild )
1616import Distribution.Types.CondTree (CondTree (.. ))
17+ import Distribution.Types.PackageName
18+ import Distribution.Types.PackageVersionConstraint (PackageVersionConstraint (.. ))
19+ import Distribution.Types.Version (Version , mkVersion )
20+ import Distribution.Types.VersionRange.Internal (VersionRange (.. ))
1721import Distribution.Verbosity
1822
1923-- TODO create tests:
@@ -24,6 +28,7 @@ parserTests = [
2428 -- testCase "read with legacy parser" testLegacyRead
2529 testCase " read packages" testPackages
2630 , testCase " read optional-packages" testOptionalPackages
31+ , testCase " read extra-packages" testExtraPackages
2732 ]
2833
2934-- Currently I compare the results of legacy parser with the new parser
@@ -51,7 +56,7 @@ testLegacyRead = do
5156
5257testPackages :: Assertion
5358testPackages = do
54- let expected = [" ." , " packages/packages.cabal" ] -- TODO https link, what does legacy parse?
59+ let expected = [" ." , " packages/packages.cabal" ] -- TODO also test https link
5560 -- Note that I currently also run the legacy parser to make sure my expected values
5661 -- do not differ from the non-Parsec implementation, this will be removed in the future
5762 (config, legacy) <- readConfigDefault " packages"
@@ -63,6 +68,15 @@ testOptionalPackages = do
6368 (config, legacy) <- readConfigDefault " optional-packages"
6469 assertConfig expected config legacy (projectPackagesOptional . condTreeData)
6570
71+ testExtraPackages :: Assertion
72+ testExtraPackages = do
73+ let expected = [
74+ PackageVersionConstraint (mkPackageName " a" ) (OrLaterVersion (mkVersion [0 ])),
75+ PackageVersionConstraint (mkPackageName " b" ) (IntersectVersionRanges (OrLaterVersion (mkVersion [0 ,7 ,3 ])) (EarlierVersion (mkVersion [0 ,9 ])))
76+ ]
77+ (config, legacy) <- readConfigDefault " extra-packages"
78+ assertConfig expected config legacy (projectPackagesNamed . condTreeData)
79+
6680readConfigDefault :: FilePath -> IO (ProjectConfigSkeleton , ProjectConfigSkeleton )
6781readConfigDefault rootFp = readConfig rootFp " cabal.project"
6882
0 commit comments