Skip to content

Commit a96eb9e

Browse files
committed
Reflect ulidtko's suggestions
Also adds a comment to explain the purpose of the random suffix
1 parent d4189fc commit a96eb9e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Stack/Build/Execute.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,12 +1928,15 @@ singleTest topts testsToRun ac ee task installedMap = do
19281928
-- see e.g. https://github.com/doctest/issues/119
19291929
-- also we set HASKELL_DIST_DIR to a package dist directory so
19301930
-- doctest will be able to load modules autogenerated by Cabal
1931-
ghcEnvRandomId <- liftIO (randomIO :: IO Int)
19321931
let setEnv f pc = modifyEnvVars pc $ \envVars ->
19331932
Map.insert "HASKELL_DIST_DIR" (T.pack $ toFilePath buildDir) $
19341933
Map.insert "GHC_ENVIRONMENT" (T.pack f) envVars
1935-
fp = toFilePath (eeTempDir ee </> testGhcEnvRelFile) <> show ghcEnvRandomId
1936-
snapDBPath = toFilePathNoTrailingSep (bcoSnapDB $ eeBaseConfigOpts ee)
1934+
fp' = eeTempDir ee </> testGhcEnvRelFile
1935+
-- Add a random suffix to avoid conflicts between parallel jobs
1936+
-- See https://github.com/commercialhaskell/stack/issues/5024
1937+
randomSuffix <- ("-"<>) . show <$> liftIO (randomIO :: IO Int)
1938+
fp <- toFilePath <$> addExtension randomSuffix fp'
1939+
let snapDBPath = toFilePathNoTrailingSep (bcoSnapDB $ eeBaseConfigOpts ee)
19371940
localDBPath = toFilePathNoTrailingSep (bcoLocalDB $ eeBaseConfigOpts ee)
19381941
ghcEnv =
19391942
"clear-package-db\n" <>

0 commit comments

Comments
 (0)