-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Randomize test-ghc-env
to avoid conflicts between parallel jobs
#5757
Conversation
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
test-ghc-env
to avoid conflicts between parallel jobs
src/Stack/Build/Execute.hs
Outdated
-- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ghcEnvRandomId
line interjects the preceding multiline comment explaining env variables and the next line, let setEnv ...
— to which that comment is relevant. Please move somewhere else.
Perhaps like this?
-- 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
let setEnv f pc = modifyEnvVars pc $ \envVars ->
Map.insert "HASKELL_DIST_DIR" (T.pack $ toFilePath buildDir) $
Map.insert "GHC_ENVIRONMENT" (T.pack f) envVars
+ ghcEnvRandomId <- liftIO (randomIO :: IO Int)
- fp = toFilePath $ eeTempDir ee </> testGhcEnvRelFile
+ let fp = toFilePath (eeTempDir ee </> testGhcEnvRelFile) <> show ghcEnvRandomId
Further, it's not so hard to stay within typed Path
, just import addExtension
:
- ghcEnvRandomId <- liftIO (randomIO :: IO Int)
- let fp = toFilePath $ eeTempDir ee </> testGhcEnvRelFile
+ randomSuffix <- ("-"<>) . show <$> liftIO (randomIO :: IO Int)
+ fp <- toFilePath <$> addExtension randomSuffix (eeTempDir ee </> testGhcEnvRelFile)
Also adds a comment to explain the purpose of the random suffix
Since the build temporary directory is shared between parallel jobs, we can't use
the same file name for the
test-ghc-env
for all of them. This PR uses a random name for each parallel job to avoid conflicts.Fixes #5024