mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-03 02:02:15 +00:00
Respect directory
option for steps again (#4319)
This commit is contained in:
@@ -16,6 +16,7 @@ package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"text/template"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -29,7 +30,7 @@ func TestGenerateScriptWin(t *testing.T) {
|
||||
from: []string{"echo %PATH%", "go build", "go test"},
|
||||
want: `
|
||||
$ErrorActionPreference = 'Stop';
|
||||
if ([Environment]::GetEnvironmentVariable('CI_WORKSPACE')) { if (-not (Test-Path "$env:CI_WORKSPACE")) { New-Item -Path "$env:CI_WORKSPACE" -ItemType Directory -Force }};
|
||||
if (-not (Test-Path "/woodpecker/some")) { New-Item -Path "/woodpecker/some" -ItemType Directory -Force };
|
||||
if (-not [Environment]::GetEnvironmentVariable('HOME')) { [Environment]::SetEnvironmentVariable('HOME', 'c:\root') };
|
||||
if (-not (Test-Path "$env:HOME")) { New-Item -Path "$env:HOME" -ItemType Directory -Force };
|
||||
if ($Env:CI_NETRC_MACHINE) {
|
||||
@@ -40,7 +41,7 @@ $netrc=[string]::Format("{0}\_netrc",$Env:HOME);
|
||||
};
|
||||
[Environment]::SetEnvironmentVariable("CI_NETRC_PASSWORD",$null);
|
||||
[Environment]::SetEnvironmentVariable("CI_SCRIPT",$null);
|
||||
if ([Environment]::GetEnvironmentVariable('CI_WORKSPACE')) { cd "$env:CI_WORKSPACE" };
|
||||
cd "/woodpecker/some";
|
||||
|
||||
Write-Output ('+ "echo %PATH%"');
|
||||
& echo %PATH%; if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
|
||||
@@ -50,12 +51,17 @@ Write-Output ('+ "go build"');
|
||||
|
||||
Write-Output ('+ "go test"');
|
||||
& go test; if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
|
||||
|
||||
`,
|
||||
},
|
||||
}
|
||||
for _, test := range testdata {
|
||||
script := generateScriptWindows(test.from)
|
||||
script := generateScriptWindows(test.from, "/woodpecker/some")
|
||||
assert.EqualValues(t, test.want, script, "Want encoded script for %s", test.from)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupScriptWinProtoParse(t *testing.T) {
|
||||
// just ensure that we have a working `setupScriptWinTmpl` on runntime
|
||||
_, err := template.New("").Parse(setupScriptWinProto)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user