Skip to content

Commit

Permalink
testscript: add ${/} as a companion to ${:} (#90)
Browse files Browse the repository at this point in the history
${:} 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.
  • Loading branch information
mvdan committed May 6, 2020
1 parent fdf702a commit a7f0f53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions testscript/testdata/exec_path_change.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# If the PATH environment variable is set in the testscript.Params.Setup phase
# or set directly within a script, exec should honour that PATH

[!windows] env HOME=$WORK/home
[windows] env HOME=$WORK\home
[windows] env USERPROFILE=$WORK\home
[windows] env LOCALAPPDATA=$WORK\appdata
[!exec:go] skip

env HOME=$WORK${/}home
[windows] env USERPROFILE=$WORK\home
[windows] env LOCALAPPDATA=$WORK\appdata

cd go
exec go$exe version
stdout 'go version'
exec go$exe build
[!windows] env PATH=$WORK/go${:}$PATH
[windows] env PATH=$WORK\go${:}$PATH
env PATH=$WORK${/}go${:}$PATH
exec go$exe version
stdout 'This is not go'

Expand Down
6 changes: 4 additions & 2 deletions testscript/testdata/stdin.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[!exec:cat] skip

stdin hello.txt
[exec:cat] exec cat
exec cat
stdout hello
[exec:cat] exec cat
exec cat
! stdout hello


Expand Down
1 change: 1 addition & 0 deletions testscript/testscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func (ts *TestScript) setup() string {
homeEnvName() + "=/no-home",
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
"devnull=" + os.DevNull,
"/=" + string(os.PathSeparator),
":=" + string(os.PathListSeparator),
},
WorkDir: ts.workdir,
Expand Down

0 comments on commit a7f0f53

Please sign in to comment.