@@ -14,6 +14,10 @@ import Distribution.Client.DistDirLayout
14
14
import Distribution.Client.ProjectConfig
15
15
import Distribution.Client.RebuildMonad (runRebuild )
16
16
import 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 (.. ))
17
21
import Distribution.Verbosity
18
22
19
23
-- TODO create tests:
@@ -24,6 +28,7 @@ parserTests = [
24
28
-- testCase "read with legacy parser" testLegacyRead
25
29
testCase " read packages" testPackages
26
30
, testCase " read optional-packages" testOptionalPackages
31
+ , testCase " read extra-packages" testExtraPackages
27
32
]
28
33
29
34
-- Currently I compare the results of legacy parser with the new parser
@@ -51,7 +56,7 @@ testLegacyRead = do
51
56
52
57
testPackages :: Assertion
53
58
testPackages = 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
55
60
-- Note that I currently also run the legacy parser to make sure my expected values
56
61
-- do not differ from the non-Parsec implementation, this will be removed in the future
57
62
(config, legacy) <- readConfigDefault " packages"
@@ -63,6 +68,15 @@ testOptionalPackages = do
63
68
(config, legacy) <- readConfigDefault " optional-packages"
64
69
assertConfig expected config legacy (projectPackagesOptional . condTreeData)
65
70
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
+
66
80
readConfigDefault :: FilePath -> IO (ProjectConfigSkeleton , ProjectConfigSkeleton )
67
81
readConfigDefault rootFp = readConfig rootFp " cabal.project"
68
82
0 commit comments