-
Notifications
You must be signed in to change notification settings - Fork 325
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
Specifying environment variables in RunSettings file #2128
Specifying environment variables in RunSettings file #2128
Conversation
src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs
Outdated
Show resolved
Hide resolved
@@ -137,6 +138,12 @@ public void Initialize(string argument) | |||
this.runSettingsManager.AddDefaultRunSettings(); | |||
|
|||
this.commandLineOptions.SettingsFile = argument; | |||
|
|||
if (this.runSettingsManager.QueryRunSettingsNode("RunConfiguration.EnvironmentVariables") != null) |
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.
"RunConfiguration.EnvironmentVariables" [](start = 65, length = 39)
Constants ?
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.
Not available
if (this.runSettingsManager.QueryRunSettingsNode("RunConfiguration.EnvironmentVariables") != null) | ||
{ | ||
this.commandLineOptions.InIsolation = true; | ||
this.runSettingsManager.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); |
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 curious, why is this required if the CLI option is already set.
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.
https://github.com/microsoft/vstest/blob/master/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs#L244 This checks inisolation node from runsettings.
test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs
Outdated
Show resolved
Hide resolved
...oft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs
Outdated
Show resolved
Hide resolved
|
||
while (childNodes.MoveNext()) | ||
{ | ||
environmentVariables.Add(childNodes.Current.Name, childNodes.Current.Value); |
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.
Checks
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.
This comes out to be always empty and never null.
The following is invalid and document fails to load.
<RunConfiguration>
<EnvironmentVariables>
<Foo>
</EnvironmentVariables>
</RunConfiguration>
<RunConfiguration> | ||
<EnvironmentVariables> | ||
<RANDOM_PATH>C:\temp</RANDOM_PATH> | ||
<RANDOM_PATH2>C:\temp2</RANDOM_PATH2> |
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.
Check for the case when user tried to add the same key twice
@@ -226,7 +226,7 @@ public void Initialize() | |||
this.dataCollectionPort = this.dataCollectionRequestSender.InitializeCommunication(); | |||
|
|||
// Warn the user that execution will wait for debugger attach. | |||
this.dataCollectionProcessId = this.dataCollectionLauncher.LaunchDataCollector(null, this.GetCommandLineArguments(this.dataCollectionPort)); | |||
this.dataCollectionProcessId = this.dataCollectionLauncher.LaunchDataCollector(InferRunSettingsHelper.GetEnvironmentVariables(SettingsXml), this.GetCommandLineArguments(this.dataCollectionPort)); | |||
EqtTrace.Info("ProxyDataCollectionManager.Initialize: Launched datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); |
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.
acollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataColl [](start = 78, length = 81)
Log env vars used to launch process
|
||
while (childNodes.MoveNext()) | ||
{ | ||
if (!environmentVariables.ContainsKey(childNodes.Current.Name)) |
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.
ContainsKey [](start = 50, length = 11)
You can use TryAdd, instead of checking and then adding.
src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs
Outdated
Show resolved
Hide resolved
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.
Very happy to see this implemented. Please cc me the next time in the implementation PR as well. Were you able to address my comment (microsoft/vstest-docs#202 (comment)) as well? |
@ViktorHofer There is no scenario where we would now be running in vstest.console, wherenever there are environment variables specified, it runs in isolation which means testhost will be spawned. |
Description
Option to specify environment variables in run settings file.
RFC: microsoft/vstest-docs#202
For example:
These are set when spawning the test host process.
Related issue
#2100