Skip to content

Commit a7f0f53

Browse files
authored
testscript: add ${/} as a companion to ${:} (#90)
${:} expands to os.PathListSeparator; now ${/} expands to os.PathSeparator. It's useful to skip windows-vs-unixy conditions, like the ones that we simplified in exec_path_change with HOME and PATH. It's also useful so that 'cmpenv stdout stdout.golden' can easily support output which contains relative file paths. While at it, make the stdin and exec_path_change scripts work on Wine (i.e. vanilla Windows), which has neither Go nor coreutils installed.
1 parent fdf702a commit a7f0f53

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

testscript/testdata/exec_path_change.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# If the PATH environment variable is set in the testscript.Params.Setup phase
22
# or set directly within a script, exec should honour that PATH
33

4-
[!windows] env HOME=$WORK/home
5-
[windows] env HOME=$WORK\home
6-
[windows] env USERPROFILE=$WORK\home
7-
[windows] env LOCALAPPDATA=$WORK\appdata
4+
[!exec:go] skip
5+
6+
env HOME=$WORK${/}home
7+
[windows] env USERPROFILE=$WORK\home
8+
[windows] env LOCALAPPDATA=$WORK\appdata
89

910
cd go
1011
exec go$exe version
1112
stdout 'go version'
1213
exec go$exe build
13-
[!windows] env PATH=$WORK/go${:}$PATH
14-
[windows] env PATH=$WORK\go${:}$PATH
14+
env PATH=$WORK${/}go${:}$PATH
1515
exec go$exe version
1616
stdout 'This is not go'
1717

testscript/testdata/stdin.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
[!exec:cat] skip
2+
13
stdin hello.txt
2-
[exec:cat] exec cat
4+
exec cat
35
stdout hello
4-
[exec:cat] exec cat
6+
exec cat
57
! stdout hello
68

79

testscript/testscript.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ func (ts *TestScript) setup() string {
297297
homeEnvName() + "=/no-home",
298298
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
299299
"devnull=" + os.DevNull,
300+
"/=" + string(os.PathSeparator),
300301
":=" + string(os.PathListSeparator),
301302
},
302303
WorkDir: ts.workdir,

0 commit comments

Comments
 (0)