Skip to content

Commit 6f637a8

Browse files
fendorFendor
authored and
Fendor
committed
Fix tests and add more normalizers
1 parent 27a9949 commit 6f637a8

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

cabal-testsuite/PackageTests/Path/All/cabal.out

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# cabal path
2-
Resolving dependencies...
32
compiler-flavour: ghc
43
compiler-id: ghc-<GHCVER>
5-
compiler-path: /home/hugin/.ghcup/bin/ghc
4+
compiler-path: <GHCPATH>
65
cache-dir: <ROOT>/cabal.dist/home/.cabal/packages
76
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
87
store-dir: <ROOT>/cabal.dist/home/.cabal/store

cabal-testsuite/src/Test/Cabal/Monad.hs

+8
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ runTestM mode m =
300300
program_db1
301301
verbosity
302302

303+
ghcLocation <- case lookupProgramByName "ghc" program_db2 of
304+
Nothing -> fail "runTestM.lookupProgramByName: No location for 'ghc' was found"
305+
Just ghcProg -> pure $ programPath ghcProg
306+
303307
program_db3 <-
304308
reconfigurePrograms verbosity
305309
([("cabal", p) | p <- maybeToList (argCabalInstallPath cargs)] ++
@@ -321,6 +325,7 @@ runTestM mode m =
321325
testProgramDb = program_db,
322326
testPlatform = platform,
323327
testCompiler = comp,
328+
testCompilerPath = ghcLocation,
324329
testPackageDBStack = db_stack,
325330
testVerbosity = verbosity,
326331
testMtimeChangeDelay = Nothing,
@@ -536,6 +541,8 @@ mkNormalizerEnv = do
536541
= addTrailingPathSeparator tmpDir,
537542
normalizerGhcVersion
538543
= compilerVersion (testCompiler env),
544+
normalizerGhcPath
545+
= testCompilerPath env,
539546
normalizerKnownPackages
540547
= mapMaybe simpleParse (words list_out),
541548
normalizerPlatform
@@ -605,6 +612,7 @@ data TestEnv = TestEnv
605612
, testProgramDb :: ProgramDb
606613
-- | Compiler we are running tests for
607614
, testCompiler :: Compiler
615+
, testCompilerPath :: FilePath
608616
-- | Platform we are running tests on
609617
, testPlatform :: Platform
610618
-- | Package database stack (actually this changes lol)

cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs

+11-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ normalizeOutput nenv =
4949
"/incoming/new-<RAND>"
5050
-- Normalize architecture
5151
. resub (posixRegexEscape (display (normalizerPlatform nenv))) "<ARCH>"
52-
. normalizeBuildInfoJson
5352
-- Some GHC versions are chattier than others
5453
. resub "^ignoring \\(possibly broken\\) abi-depends field for packages" ""
5554
-- Normalize the current GHC version. Apply this BEFORE packageIdRegex,
@@ -63,19 +62,28 @@ normalizeOutput nenv =
6362
++ "(-[a-z0-9]+)?")
6463
"<GHCVER>"
6564
else id)
65+
. normalizeBuildInfoJson
66+
. normalizePathCmdOutput
6667
-- hackage-security locks occur non-deterministically
6768
. resub "(Released|Acquired|Waiting) .*hackage-security-lock\n" ""
6869
where
6970
packageIdRegex pid =
7071
resub (posixRegexEscape (display pid) ++ "(-[A-Za-z0-9.-]+)?")
7172
(prettyShow (packageName pid) ++ "-<VERSION>")
7273

74+
normalizePathCmdOutput =
75+
-- clear the ghc path out of all supported output formats
76+
resub ("compiler-path: " <> posixRegexEscape (normalizerGhcPath nenv))
77+
"compiler-path: <GHCPATH>"
78+
. resub ("\"compiler-path\"\\s*:\\s*\"" <> posixRegexEscape (normalizerGhcPath nenv) <> "\"")
79+
"\"compiler-path\": \"<GHCPATH>\""
80+
7381
-- 'build-info.json' contains a plethora of host system specific information.
7482
--
7583
-- This must happen before the root-dir normalisation.
7684
normalizeBuildInfoJson =
7785
-- Remove ghc path from show-build-info output
78-
resub ("\"path\":\"[^\"]*\"}")
86+
resub ("\"path\":\"" <> posixRegexEscape (normalizerGhcPath nenv) <> "\"}")
7987
"\"path\":\"<GHCPATH>\"}"
8088
-- Remove cabal version output from show-build-info output
8189
. resub ("{\"cabal-version\":\"" ++ posixRegexEscape (display (normalizerCabalVersion nenv)) ++ "\"")
@@ -104,6 +112,7 @@ data NormalizerEnv = NormalizerEnv
104112
-- `/var` is a symlink for `/private/var`.
105113
, normalizerGblTmpDir :: FilePath
106114
, normalizerGhcVersion :: Version
115+
, normalizerGhcPath :: FilePath
107116
, normalizerKnownPackages :: [PackageId]
108117
, normalizerPlatform :: Platform
109118
, normalizerCabalVersion :: Version

cabal-testsuite/src/Test/Cabal/Prelude.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,11 @@ cabalGArgs global_args cmd args input = do
302302
, "info"
303303
, "init"
304304
, "haddock-project"
305-
, "path"
306305
]
307306
= [ ]
308307

309308
-- new-build commands are affected by testCabalProjectFile
310-
| cmd == "v2-sdist"
309+
| cmd `elem` ["v2-sdist", "path"]
311310
= [ "--project-file=" ++ fp | Just fp <- [testCabalProjectFile env] ]
312311

313312
| cmd == "v2-clean"

0 commit comments

Comments
 (0)