22module IntegrationTests2.ProjectConfig.ParsecTests (parserTests ) where
33
44import qualified Data.ByteString as BS
5+ import Data.Either
56import Distribution.Client.DistDirLayout
67import Distribution.Client.HttpUtils
78import Distribution.Client.ProjectConfig
@@ -12,14 +13,13 @@ import Distribution.Types.CondTree (CondTree (..))
1213import Distribution.Types.PackageName
1314import Distribution.Types.PackageVersionConstraint (PackageVersionConstraint (.. ))
1415import Distribution.Types.SourceRepo (KnownRepoType (.. ), RepoType (.. ))
15- import Distribution.Types.Version (Version , mkVersion )
16+ import Distribution.Types.Version (mkVersion )
1617import Distribution.Types.VersionRange.Internal (VersionRange (.. ))
1718import Distribution.Verbosity
1819import System.Directory
1920import System.FilePath
2021import Test.Tasty
2122import Test.Tasty.HUnit
22- import Test.Tasty.Options
2323
2424-- TODO create tests:
2525-- - parser tests to read and compare to expected values
@@ -81,12 +81,8 @@ testExtraPackages = do
8181readConfigDefault :: FilePath -> IO (ProjectConfigSkeleton , ProjectConfigSkeleton )
8282readConfigDefault rootFp = readConfig rootFp " cabal.project"
8383
84- -- TODO this is an overkill, look at warningTests, they just use runParseResult without
85- -- httpTransport etc
8684readConfig :: FilePath -> FilePath -> IO (ProjectConfigSkeleton , ProjectConfigSkeleton )
8785readConfig rootFp projectFileName = do
88- -- TODO extract argument so it can be mocked
89- httpTransport <- configureTransport verbosity [] Nothing
9086 projectRootDir <- canonicalizePath (basedir </> rootFp)
9187
9288 let projectRoot = ProjectRootExplicit projectRootDir projectFileName
@@ -96,9 +92,11 @@ readConfig rootFp projectFileName = do
9692 distProjectConfigFp = distProjectFile distDirLayout extensionName
9793 exists <- doesFileExist distProjectConfigFp
9894 assertBool (" projectConfig does not exist: " <> distProjectConfigFp) exists
99- parsec <-
100- runRebuild projectRootDir $
101- readProjectFileSkeleton verbosity httpTransport distDirLayout extensionName extensionDescription
95+ contents <- BS. readFile distProjectConfigFp
96+ let (_, res) = runParseResult $ parseProjectSkeleton contents
97+ assertBool (" should parse successfully: " ++ show res) $ isRight res
98+ let parsec = fromRight undefined res
99+ httpTransport <- configureTransport verbosity [] Nothing
102100 legacy <-
103101 runRebuild projectRootDir $
104102 readProjectFileSkeletonLegacy verbosity httpTransport distDirLayout extensionName extensionDescription
@@ -118,9 +116,6 @@ assertConfig expected config configLegacy access = do
118116 actualLegacy = access configLegacy
119117
120118-- | Test Utilities
121- emptyProjectConfig :: ProjectConfig
122- emptyProjectConfig = mempty
123-
124119verbosity :: Verbosity
125120verbosity = normal -- minBound --normal --verbose --maxBound --minBound
126121
0 commit comments