text = string(data)
}
- // Matching against workdir would be misleading.
- text = strings.ReplaceAll(text, s.workdir, "$WORK")
-
if n > 0 {
count := len(re.FindAllString(text, -1))
if count != n {
return os.Expand(str, func(key string) string {
e := s.envMap[key]
if inRegexp {
- // Replace workdir with $WORK, since we have done the same substitution in
- // the text we're about to compare against.
- //
- // TODO(bcmills): This seems out-of-place in the script engine.
- // See if we can remove it.
- e = strings.ReplaceAll(e, s.workdir, "$WORK")
-
// Quote to literal strings: we want paths like C:\work\go1.4 to remain
// paths rather than regular expressions.
e = regexp.QuoteMeta(e)
t.Fatal(err)
}
- if *testWork {
- work, _ := s.LookupEnv("WORK")
- t.Logf("$WORK=%s", work)
- }
t.Log(time.Now().UTC().Format(time.RFC3339))
+ work, _ := s.LookupEnv("WORK")
+ t.Logf("$WORK=%s", work)
// With -testsum, if a go.mod file is present in the test's initial
// working directory, run 'go mod tidy'.
# See issue golang.org/issue/37012.
go build -n
! stderr '[/\\]\$WORK'
+stderr '[ =]\$WORK'
-- go.mod --
module m
mkdir tmp
env GOTMPDIR=tmp
go build -work a
-stderr 'WORK=\$WORK' # the test script itself converts the absolute directory back to $WORK
+stderr 'WORK='$WORK
# Similarly if TMP/TMPDIR is relative.
env GOTMPDIR=
env TMP=tmp # Windows
env TMPDIR=tmp # Unix
go build -work a
-stderr 'WORK=\$WORK'
+stderr 'WORK='$WORK
-- a/a.go --
package a
# With all three set, we should prefer GOCACHE.
go env GOCACHE
-stdout '\$WORK/gocache$'
+stdout $WORK'/gocache$'
# Without GOCACHE, we should prefer XDG_CACHE_HOME over HOME.
env GOCACHE=
go env GOCACHE
-stdout '\$WORK/xdg/go-build$$'
+stdout $WORK'/xdg/go-build$$'
# With only HOME set, we should use $HOME/.cache.
env XDG_CACHE_HOME=
go env GOCACHE
-stdout '\$WORK/home/.cache/go-build$'
+stdout $WORK'/home/.cache/go-build$'
# With no guidance from the environment, we must disable the cache, but that
# should not cause commands that do not write to the cache to fail.
cd $WORK
go list -e -f {{.Error}} .
-stdout 'no Go files in \$WORK'
+stdout 'no Go files in '$WORK
go list -e -f {{.Error}} ./empty
-stdout 'no Go files in \$WORK[/\\]empty'
+stdout 'no Go files in '$WORK${/}'empty'
go list -e -f {{.Error}} ./exclude
-stdout 'build constraints exclude all Go files in \$WORK[/\\]exclude'
+stdout 'build constraints exclude all Go files in '$WORK${/}'exclude'
go list -e -f {{.Error}} ./missing
stdout 'stat '$WORK'[/\\]missing: directory not found'
# use 'go build -n' because 'go list' reports no error.
! go build -n ./testonly
-stderr 'example.com/m/testonly: no non-test Go files in \$WORK[/\\]testonly'
+stderr 'example.com/m/testonly: no non-test Go files in '$WORK${/}'testonly'
-- $WORK/go.mod --
module example.com/m
env GO111MODULE=on
exec $WORK/testfindonly$GOEXE gobuild.example.com/x/y/z/i $WORK
! stdout 'build constraints'
-stdout '^dir=\$WORK.+i err=<nil>$'
+stdout '^dir='$WORK'.+i err=<nil>$'
# Issue 37153: Import with empty srcDir should work.
env GO111MODULE=on
exec $WORK/testfindonly$GOEXE gobuild.example.com/x/y/z/i ''
! stdout 'build constraints'
-stdout '^dir=\$WORK.+i err=<nil>$'
+stdout '^dir='$WORK'.+i err=<nil>$'
-- go.mod --
module gobuild.example.com/x/y/z
# 'go env GOMOD' should print the path to the real file.
# 'go env' does not recognize the '-modfile' flag.
go env GOMOD
-stdout '^\$WORK[/\\]gopath[/\\]src[/\\]go.mod$'
+stdout '^'$WORK${/}gopath${/}src${/}'go\.mod$'
# 'go list -m' should print the effective go.mod file as GoMod though.
go list -m -f '{{.GoMod}}'