Skip to content

Commit fe761f9

Browse files
committed
Make test-ghc-env files unique across parallel jobs
Since the build temporary directory is shared between jobs, we can't use the same file name for the `test-ghc-env` for all of them. Fixes #5024
1 parent 69f55d4 commit fe761f9

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ dependencies:
104104
- primitive
105105
- process
106106
- project-template
107+
- random
107108
- retry
108109
- rio >= 0.1.21.0
109110
- rio-prettyprint >= 0.1.1.0

src/Stack/Build/Execute.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import System.PosixCompat.Files (createLink, modificationTime, getFile
9393
import RIO.PrettyPrint
9494
import RIO.Process
9595
import Pantry.Internal.Companion
96+
import System.Random (randomIO)
9697

9798
-- | Has an executable been built or not?
9899
data ExecutableBuildStatus
@@ -1918,10 +1919,11 @@ singleTest topts testsToRun ac ee task installedMap = do
19181919
-- see e.g. https://github.com/doctest/issues/119
19191920
-- also we set HASKELL_DIST_DIR to a package dist directory so
19201921
-- doctest will be able to load modules autogenerated by Cabal
1922+
ghcEnvRandomId <- liftIO (randomIO :: IO Int)
19211923
let setEnv f pc = modifyEnvVars pc $ \envVars ->
19221924
Map.insert "HASKELL_DIST_DIR" (T.pack $ toFilePath buildDir) $
19231925
Map.insert "GHC_ENVIRONMENT" (T.pack f) envVars
1924-
fp = toFilePath $ eeTempDir ee </> testGhcEnvRelFile
1926+
fp = toFilePath (eeTempDir ee </> testGhcEnvRelFile) <> show ghcEnvRandomId
19251927
snapDBPath = toFilePathNoTrailingSep (bcoSnapDB $ eeBaseConfigOpts ee)
19261928
localDBPath = toFilePathNoTrailingSep (bcoLocalDB $ eeBaseConfigOpts ee)
19271929
ghcEnv =

stack.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ library
282282
, primitive
283283
, process
284284
, project-template
285+
, random
285286
, retry
286287
, rio >=0.1.21.0
287288
, rio-prettyprint >=0.1.1.0
@@ -405,6 +406,7 @@ executable stack
405406
, primitive
406407
, process
407408
, project-template
409+
, random
408410
, retry
409411
, rio >=0.1.21.0
410412
, rio-prettyprint >=0.1.1.0
@@ -527,6 +529,7 @@ executable stack-integration-test
527529
, primitive
528530
, process
529531
, project-template
532+
, random
530533
, retry
531534
, rio >=0.1.21.0
532535
, rio-prettyprint >=0.1.1.0
@@ -654,6 +657,7 @@ test-suite stack-test
654657
, primitive
655658
, process
656659
, project-template
660+
, random
657661
, raw-strings-qq
658662
, retry
659663
, rio >=0.1.21.0

0 commit comments

Comments
 (0)