Filter NODE_OPTIONS from env for file output (#2775)

Copies logic that used to be in ::set::env before its deprecation
This commit is contained in:
Cory Miller
2023-08-16 17:56:01 -04:00
committed by GitHub
parent 460d9ae5a8
commit 8b9a81c952
2 changed files with 68 additions and 0 deletions

View File

@@ -183,6 +183,47 @@ namespace GitHub.Runner.Common.Tests.Worker
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetEnvFileCommand_BlockListItemsFiltered()
{
using (var hostContext = Setup())
{
var stateFile = Path.Combine(_rootDirectory, "simple");
var content = new List<string>
{
"NODE_OPTIONS=asdf",
};
WriteContent(stateFile, content);
_setEnvFileCommand.ProcessCommand(_executionContext.Object, stateFile, null);
Assert.Equal(1, _issues.Count);
Assert.Equal(0, _executionContext.Object.Global.EnvironmentVariables.Count);
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetEnvFileCommand_BlockListItemsFiltered_Heredoc()
{
using (var hostContext = Setup())
{
var stateFile = Path.Combine(_rootDirectory, "simple");
var content = new List<string>
{
"NODE_OPTIONS<<EOF",
"asdf",
"EOF",
};
WriteContent(stateFile, content);
_setEnvFileCommand.ProcessCommand(_executionContext.Object, stateFile, null);
Assert.Equal(1, _issues.Count);
Assert.Equal(0, _executionContext.Object.Global.EnvironmentVariables.Count);
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]