Commit bf005a8b authored by Arran Walker's avatar Arran Walker

Ensure Powershell file variables contain no BOM

parent bac13a39
......@@ -215,6 +215,30 @@ func TestDockerCommandSuccessRunRawVariable(t *testing.T) {
assert.Contains(t, out, value)
}
func TestDockerCommandSuccessRunFileVariable(t *testing.T) {
helpers.SkipIntegrationTests(t, "docker", "info")
test.SkipIfGitLabCIOn(t, test.OSWindows)
build := getBuildForOS(t, func() (common.JobResponse, error) {
if runtime.GOOS == "windows" {
return common.GetRemoteBuildResponse(`Get-Filehash -Algorithm SHA1 -Path $TEST`)
}
return common.GetRemoteBuildResponse(`sha1sum $TEST | tr "[a-z]" "[A-Z]"`)
})
build.Variables = append(build.Variables, common.JobVariable{
Key: "TEST",
Value: "this is the content",
File: true,
Raw: true,
})
out, err := buildtest.RunBuildReturningOutput(t, &build)
assert.NoError(t, err)
// assert contains sha1 of 'this is the content'
assert.Contains(t, out, "A12947AAF74BCCE2D0114CF0C62C387C3E60B2FC")
}
func TestDockerCommandUsingCustomClonePath(t *testing.T) {
helpers.SkipIntegrationTests(t, "docker", "info")
test.SkipIfGitLabCIOn(t, test.OSWindows)
......
......@@ -129,7 +129,7 @@ func (p *PsWriter) Variable(variable common.JobVariable) {
psQuote(p.fromSlash(p.TemporaryPath)),
)
p.Linef(
"Set-Content %s -Value %s -Encoding UTF8 -Force",
"[System.IO.File]::WriteAllText(%s, %s)",
psQuote(variableFile),
psQuoteVariable(variable.Value),
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment