Skip to content

Commit

Permalink
Make test-ghc-env files unique across parallel jobs
Browse files Browse the repository at this point in the history
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 commercialhaskell#5024
  • Loading branch information
zyla committed Oct 27, 2021
1 parent 69f55d4 commit fe761f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ dependencies:
- primitive
- process
- project-template
- random
- retry
- rio >= 0.1.21.0
- rio-prettyprint >= 0.1.1.0
Expand Down
4 changes: 3 additions & 1 deletion src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import System.PosixCompat.Files (createLink, modificationTime, getFile
import RIO.PrettyPrint
import RIO.Process
import Pantry.Internal.Companion
import System.Random (randomIO)

-- | Has an executable been built or not?
data ExecutableBuildStatus
Expand Down Expand Up @@ -1918,10 +1919,11 @@ singleTest topts testsToRun ac ee task installedMap = do
-- see e.g. https://github.com/doctest/issues/119
-- also we set HASKELL_DIST_DIR to a package dist directory so
-- doctest will be able to load modules autogenerated by Cabal
ghcEnvRandomId <- liftIO (randomIO :: IO Int)
let setEnv f pc = modifyEnvVars pc $ \envVars ->
Map.insert "HASKELL_DIST_DIR" (T.pack $ toFilePath buildDir) $
Map.insert "GHC_ENVIRONMENT" (T.pack f) envVars
fp = toFilePath $ eeTempDir ee </> testGhcEnvRelFile
fp = toFilePath (eeTempDir ee </> testGhcEnvRelFile) <> show ghcEnvRandomId
snapDBPath = toFilePathNoTrailingSep (bcoSnapDB $ eeBaseConfigOpts ee)
localDBPath = toFilePathNoTrailingSep (bcoLocalDB $ eeBaseConfigOpts ee)
ghcEnv =
Expand Down
4 changes: 4 additions & 0 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ library
, primitive
, process
, project-template
, random
, retry
, rio >=0.1.21.0
, rio-prettyprint >=0.1.1.0
Expand Down Expand Up @@ -405,6 +406,7 @@ executable stack
, primitive
, process
, project-template
, random
, retry
, rio >=0.1.21.0
, rio-prettyprint >=0.1.1.0
Expand Down Expand Up @@ -527,6 +529,7 @@ executable stack-integration-test
, primitive
, process
, project-template
, random
, retry
, rio >=0.1.21.0
, rio-prettyprint >=0.1.1.0
Expand Down Expand Up @@ -654,6 +657,7 @@ test-suite stack-test
, primitive
, process
, project-template
, random
, raw-strings-qq
, retry
, rio >=0.1.21.0
Expand Down

0 comments on commit fe761f9

Please sign in to comment.