Skip to content

Commit 003bb41

Browse files
rolfbjarnemandel-macaque
authored andcommitted
[xharness] Allow for null environment variables to mlaunch. (#9140)
It's a valid scenario to set a null environment variable. This happens when changing InCI to always return true (to test locally what's done on the bots), in which case we try to forward BUILD_REVISION to mlaunch, but BUILD_REVISION isn't necessarily set. Not forwarding it to mlaunch should not cause problems in most tests, so just allow this scenario.
1 parent 42f2fde commit 003bb41

File tree

1 file changed

+4
-3
lines changed
  • tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Execution/Mlaunch

1 file changed

+4
-3
lines changed

tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Execution/Mlaunch/Arguments.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ public sealed class SetEnvVariableArgument : MlaunchArgument {
181181
public SetEnvVariableArgument (string variableName, object variableValue)
182182
{
183183
this.variableName = variableName ?? throw new ArgumentNullException (nameof (variableName));
184-
this.variableValue = variableValue?.ToString () ?? throw new ArgumentNullException (nameof (variableValue));
185184

186-
if (variableValue is bool)
187-
this.variableValue = this.variableValue.ToLower ();
185+
if (variableValue is bool b)
186+
this.variableValue = b.ToString ().ToLowerInvariant ();
187+
else
188+
this.variableValue = variableValue?.ToString ();
188189
}
189190

190191
public override string AsCommandLineArgument () => Escape ($"-setenv={variableName}={variableValue}");

0 commit comments

Comments
 (0)