|
| 1 | +-- | Integration Tests related to parsing of ProjectConfigs |
| 2 | + |
| 3 | +module IntegrationTests2.ProjectConfig.ParsecTests (parserTests) where |
| 4 | + |
| 5 | +import qualified Data.ByteString as BS |
| 6 | +import System.Directory |
| 7 | +import System.FilePath |
| 8 | +import Test.Tasty |
| 9 | +import Test.Tasty.HUnit |
| 10 | +import Test.Tasty.Options |
| 11 | + |
| 12 | +import Distribution.Client.HttpUtils |
| 13 | +import Distribution.Client.DistDirLayout |
| 14 | +import Distribution.Client.ProjectConfig |
| 15 | +import Distribution.Client.RebuildMonad (runRebuild) |
| 16 | +import Distribution.Verbosity |
| 17 | + |
| 18 | +-- TODO create tests: |
| 19 | +-- - parser tests to read and compare to expected values |
| 20 | +-- - golden tests for warnings and errors |
| 21 | +parserTests :: [TestTree] |
| 22 | +parserTests = [ |
| 23 | + testCase "read with legacy parser" testLegacyRead |
| 24 | + ] |
| 25 | + |
| 26 | +-- Currently I compare the results of legacy parser with the new parser |
| 27 | +-- When the parser is implemented I will migrate it to compare to actual values |
| 28 | +testLegacyRead :: Assertion |
| 29 | +testLegacyRead = do |
| 30 | + httpTransport <- configureTransport verbosity [] Nothing |
| 31 | + let testdir = "ProjectConfig/files/" |
| 32 | + projectRootDir <- canonicalizePath (basedir </> testdir) |
| 33 | + |
| 34 | + -- let projectRoot = ProjectRootImplicit projectRootDir |
| 35 | + let projectFileName = "cabal-minimal.project" |
| 36 | + projectRoot = ProjectRootExplicit projectRootDir projectFileName |
| 37 | + extensionName = "" |
| 38 | + distDirLayout = defaultDistDirLayout projectRoot Nothing |
| 39 | + extensionDescription = "description" |
| 40 | + distProjectConfigFp = distProjectFile distDirLayout extensionName |
| 41 | + print distProjectConfigFp |
| 42 | + exists <- doesFileExist distProjectConfigFp |
| 43 | + print $ exists |
| 44 | + projectConfigSkeletonLegacy <- runRebuild projectRootDir $ |
| 45 | + readProjectFileSkeletonLegacy verbosity httpTransport distDirLayout extensionName extensionDescription |
| 46 | + projectConfigSkeleton <- runRebuild projectRootDir $ |
| 47 | + readProjectFileSkeleton verbosity httpTransport distDirLayout extensionName extensionDescription |
| 48 | + projectConfigSkeleton @?= projectConfigSkeletonLegacy |
| 49 | + |
| 50 | +-- | Test Utilities |
| 51 | +emptyProjectConfig :: ProjectConfig |
| 52 | +emptyProjectConfig = mempty |
| 53 | + |
| 54 | +verbosity :: Verbosity |
| 55 | +verbosity = minBound --normal --verbose --maxBound --minBound |
| 56 | + |
| 57 | +basedir :: FilePath |
| 58 | +basedir = "tests" </> "IntegrationTests2" |
0 commit comments