-
Notifications
You must be signed in to change notification settings - Fork 202
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
Use nailgun environment in forked processes #413
Conversation
@@ -9,8 +9,8 @@ object Integrations { | |||
val MiniBetterFiles = RootProject(uri( | |||
"git://github.com/scalacenter/mini-better-files.git#0ed848993a2fd5a36e4366b5efb9c68dce958fc2")) | |||
val WithResources = RootProject( | |||
uri("git://github.com/scalacenter/with-resources.git#7529b2c3ac455cbb1889d4791c4e0d4957e29306")) | |||
uri("git://github.com/scalacenter/with-resources.git#f0a46830cae7ef6282d9bba64b6da34bae18f339")) |
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.
These new hashes contain modifications to the dummy code to fail if the env variable BLOOP_OWNER
is not accessible via sys.env
.
What this means is that now Bloop will use the environment variable of the places where the bloop client is involved (e.g. your terminal) to run and test code. |
5d35914
to
e161985
Compare
This is ready for review 🎉. |
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.
Some minor comment, and a question.
Are we sure that we want to remove everything from a forked process' environment before adding more values? Could we be discarding values that users would expect to be present in the environment?
@@ -47,6 +47,7 @@ final case class ForkProcess(javaEnv: JavaEnv, classpath: Array[AbsolutePath]) { | |||
className: String, | |||
args: Array[String], | |||
logger: Logger, | |||
env: Properties, |
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.
Javadoc needs updating
@@ -68,6 +69,9 @@ final case class ForkProcess(javaEnv: JavaEnv, classpath: Array[AbsolutePath]) { | |||
} else { | |||
val processBuilder = new ProcessBuilder(cmd: _*) | |||
processBuilder.directory(cwd.toFile) | |||
val processEnv = processBuilder.environment() | |||
processEnv.clear() | |||
env.forEach { case (k: String, v: String) => processEnv.put(k, v); () } |
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.
I think that you can use putAll
here
@@ -68,6 +69,9 @@ final case class ForkProcess(javaEnv: JavaEnv, classpath: Array[AbsolutePath]) { | |||
} else { | |||
val processBuilder = new ProcessBuilder(cmd: _*) | |||
processBuilder.directory(cwd.toFile) | |||
val processEnv = processBuilder.environment() | |||
processEnv.clear() |
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.
Are we sure that we want to discard everything?
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.
Yeah, I elaborated on my other comment.
@@ -79,7 +73,8 @@ object TestInternals { | |||
fork: ForkProcess, | |||
discoveredTests: DiscoveredTests, | |||
eventHandler: EventHandler, | |||
logger: Logger): Unit = { | |||
logger: Logger, | |||
env: Properties): Unit = { |
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.
Javadoc needs updating
import scala.collection.JavaConverters._ | ||
System.getenv().asScala.foldLeft(new Properties()) { | ||
case (props, (key, value)) => props.setProperty(key, value); props | ||
} |
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.
Just use clone
?
This PR will not expose any of the server's environment variables to the test and run tasks, so yeah, if users expect those to be in they won't. I think that doing this is the right behaviour, and it's very unlikely someone would want env variables from the server for these particular tasks. However, the rest of the tasks will still use the environment variables of the server (as expected). |
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.
LGTM
0bfacfe
to
704169e
Compare
This commit propagates the `remoteEnv` properties in the nailgun context to the place where we run and test projects in forked projects. Thanks to the fact that we always fork, we're able to use the environment variables from the user without weird hacks to mutate `System.getenv` and scope it per client. Fixes #335.
The problem is that we were expecting 5 sources instead of 6. This commit fixes that and adds more cases to make the whole test more reliable.
Something is acting up.
704169e
to
87181dc
Compare
This commit propagates the
remoteEnv
properties in the nailgun contextto the place where we run and test projects in forked projects. Thanks
to the fact that we always fork, we're able to use the environment
variables from the user without weird hacks to mutate
System.getenv
and scope it per client.
Fixes #335.