Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: ensure that tests do not write to the current directory #28387

Open
bcmills opened this issue Oct 25, 2018 · 17 comments

Comments

@bcmills
Copy link
Member

commented Oct 25, 2018

In #27957, @hyangah noticed that the tests for compress/bzip2 fail when GOROOT is not writable, and those tests are run whenever we run go test all in module mode (which is intended to be a useful default).

As noted in #28386, tests should not assume that they can write to the current directory. We should ensure that none of the tests in the standard library make that mistake.

@tkivisik

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2018

Does that mean the following pattern would be fine (create and use a temporary folder)
e.g.

wd, _ := os.Getwd()
dir, err := ioutil.TempDir("", "testing")
if err != nil {
	log.Fatal(err)
}
defer os.RemoveAll(dir) // clean up
// change and restore finally
if err := os.Chdir(dir); err != nil {
	return
}
defer os.Chdir(wd)
// Create necessary files for a test
// Run tests
@dpinela

This comment has been minimized.

Copy link
Contributor

commented Oct 28, 2018

@bcmills It isn't the tests for compress/bzip2 that fail in #27957, it's the ones for compress/flate, and in that particular case it only happens when they would fail anyway - they write the actual output to testdata/*.got when actual != expected. Considering these files need to outlive the test, I'm not sure where else we should put them. On the other hand, this case might be fine - if your GOROOT is read-only, then you're probably using a stable release of Go, which presumably means the tests are passing; if they're not, you're using a dev tree, which is almost certainly writable.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 28, 2018

Change https://golang.org/cl/145283 mentions this issue: os: ensure tests pass even if GOROOT is read-only

gopherbot pushed a commit that referenced this issue Oct 28, 2018
os: ensure tests pass even if GOROOT is read-only
We achieve this by always running all tests that create files in a
fresh temporary directory, rather than just on darwin/{arm,arm64}.
As a bonus, this lets us simplify the cleanup code for these tests
and assume their working directory starts out empty.

Updates #28387

Change-Id: I952007ae390a2451c9a368da26c7f9f5af64b2ba
Reviewed-on: https://go-review.googlesource.com/c/145283
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@bcmills

This comment has been minimized.

Copy link
Member Author

commented Oct 29, 2018

@tkivisik, yes, but in most cases you shouldn't even need to bother with Getwd and Chdir.

I've found this pattern pretty helpful:

	dir, err := ioutil.TempDir("", path.Base(t.Name()))
	if err != nil {
		t.Fatal(err)
	}
	defer os.RemoveAll(dir)

I wonder whether we should just make that a method on *testing.T: the os.RemoveAll doesn't strictly need to be deferred right there at the call site (we can run it at any point after the test function returns), and it might be useful to have a standard flag (along the lines of -work) to leave the temporary directory in place.

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Oct 29, 2018

@dpinela

Considering these files need to outlive the test, I'm not sure where else we should put them.

Do they belong in side-files at all, given that the -update flag is not set? It seems like most regressions will be fairly small diffs, in which case we could log the first few lines of the diff — and that would also make the failure logs more useful if the reader doesn't have filesystem access (such as in the case of a TryBot failure).

If someone wants to dig in and fix a massive regression, they can always use -update and look at the diff using git diff instead of a separate side file.

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Oct 29, 2018

if your GOROOT is read-only, then you're probably using a stable release of Go, which presumably means the tests are passing

That's not a valid assumption in general. Platform- or architecture-dependent bugs and non-hermetic tests can all lead to failures even with a stable release.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 30, 2018

Change https://golang.org/cl/146119 mentions this issue: go/internal/gcimporter: ensure tests pass even if GOROOT is read-only

gopherbot pushed a commit that referenced this issue Nov 6, 2018
go/internal/gcimporter: ensure tests pass even if GOROOT is read-only
This mainly entails writing compiler output files to a temporary
directory, as well as the corrupted files in TestVersionHandling.

Updates #28387

Change-Id: I6b3619a91fff27011c7d73daa4febd14a6c5c348
Reviewed-on: https://go-review.googlesource.com/c/146119
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>

@ianlancetaylor ianlancetaylor modified the milestones: Go1.12, Unplanned Nov 29, 2018

@darkfeline

This comment has been minimized.

Copy link

commented Feb 4, 2019

The tests for os appear to be affected by this (the bug currently only mentions compress/bzip2 so I thought I should point it out). (#29676)

--- FAIL: TestStatError (0.00s)
    os_test.go:200: symlink no-such-file symlink: permission denied
--- FAIL: TestHardLink (0.00s)
    os_test.go:694: open "hardlinktestto" failed: open hardlinktestto: permission denied
--- FAIL: TestSymlink (0.00s)
    os_test.go:780: Create("symlinktestto") failed: open symlinktestto: permission denied
--- FAIL: TestLongSymlink (0.00s)
    os_test.go:847: symlink "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "longsymlinktestfrom" failed: symlink 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef longsymlinktestfrom: permission denied
--- FAIL: TestRename (0.00s)
    os_test.go:868: open "renamefrom" failed: open renamefrom: permission denied
--- FAIL: TestRenameOverwriteDest (0.00s)
    os_test.go:896: write file "renameto" failed: open renameto: permission denied
--- FAIL: TestAppend (0.00s)
    os_test.go:1684: Open: open append.txt: permission denied
--- FAIL: TestSameFile (0.00s)
    os_test.go:1766: Create(a): open a: permission denied
FAIL
FAIL	os	18.381s
@dpinela

This comment has been minimized.

Copy link
Contributor

commented Feb 9, 2019

@darkfeline Is that on tip? I think these failures are already fixed there. Just ran them again to check.

@darkfeline

This comment has been minimized.

Copy link

commented Feb 18, 2019

@dpinela yes it is fixed on master, I had only checked the latest release.

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/163037 mentions this issue: cmd/vet: do not write test vet binary to GOROOT

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162987 mentions this issue: unix: do not invoke Mkfifo with a relative path in a read-only directory

gopherbot pushed a commit to golang/sys that referenced this issue Feb 19, 2019
unix: do not invoke Mkfifo with a relative path in a read-only directory
Updates golang/go#28387

Change-Id: Ibcdc3f9cb3dc43b86b7e7d3539ed592219e54aba
Reviewed-on: https://go-review.googlesource.com/c/162987
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
gopherbot pushed a commit that referenced this issue Feb 19, 2019
cmd/vet: do not write test vet binary to GOROOT
Updates #28387

Change-Id: Ie5a5f1f798eb5900f9c7bdef165abcca02dd0dde
Reviewed-on: https://go-review.googlesource.com/c/163037
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
nebulabox added a commit to nebulabox/go that referenced this issue Feb 20, 2019
cmd/vet: do not write test vet binary to GOROOT
Updates golang#28387

Change-Id: Ie5a5f1f798eb5900f9c7bdef165abcca02dd0dde
Reviewed-on: https://go-review.googlesource.com/c/163037
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
nebulabox added a commit to nebulabox/go that referenced this issue Feb 20, 2019
cmd/vet: do not write test vet binary to GOROOT
Updates golang#28387

Change-Id: Ie5a5f1f798eb5900f9c7bdef165abcca02dd0dde
Reviewed-on: https://go-review.googlesource.com/c/163037
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Feb 22, 2019

Change https://golang.org/cl/163214 mentions this issue: misc/cgo/testplugin: convert test.bash to Go and fix in module mode

@gopherbot

This comment has been minimized.

Copy link

commented Feb 22, 2019

Change https://golang.org/cl/163420 mentions this issue: misc/cgo/testso{,var}: fix tests in module mode

gopherbot pushed a commit that referenced this issue Feb 24, 2019
misc/cgo/testplugin: convert test.bash to Go and fix in module mode
Updates #30228
Updates #28387

Change-Id: Iad7d960b70221f90ccc2372bb1d4d41cec3926e4
Reviewed-on: https://go-review.googlesource.com/c/163214
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue Feb 26, 2019
misc/cgo/testso{,var}: fix tests in module mode
Add _test.go files in the individal directories to invoke 'go build'
with appropriate arguments.

Move the test driver out of cmd/dist so that it's easier to invoke the
test separately (using 'go test .').

Updates #30228
Updates #28387

Change-Id: Ibc4a024a52c12a274058298b41cc90709f7f56c8
Reviewed-on: https://go-review.googlesource.com/c/163420
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@bcmills

This comment has been minimized.

Copy link
Member Author

commented Mar 11, 2019

Remaining short-mode failures seem to be exclusively in cmd/go:

--- FAIL: TestLocalImportsEasy (0.36s)
    go_test.go:1046: running testgo [build -o ./easy testdata/local/easy.go]
    go_test.go:1046: standard error:
    go_test.go:1046: go build command-line-arguments: open ./easy: permission denied

    go_test.go:1046: go [build -o ./easy testdata/local/easy.go] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestLocalImportsEasySub (0.31s)
    go_test.go:1052: running testgo [build -o ./easysub testdata/local/easysub/main.go]
    go_test.go:1052: standard error:
    go_test.go:1052: go build command-line-arguments: open ./easysub: permission denied

    go_test.go:1052: go [build -o ./easysub testdata/local/easysub/main.go] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestLocalImportsHard (0.40s)
    go_test.go:1058: running testgo [build -o ./hard testdata/local/hard.go]
    go_test.go:1058: standard error:
    go_test.go:1058: go build command-line-arguments: open ./hard: permission denied

    go_test.go:1058: go [build -o ./hard testdata/local/hard.go] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestInstallIntoGOPATH (0.18s)
    go_test.go:1511: running testgo [install go-cmd-test]
    go_test.go:1511: standard error:
    go_test.go:1511: go install go-cmd-test: open /usr/local/google/home/bcmills/go/src/cmd/go/testdata/bin/go-cmd-test: permission denied

    go_test.go:1511: go [install go-cmd-test] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestInstallIntoGOBIN (0.14s)
    go_test.go:1610: running testgo [install go-cmd-test]
    go_test.go:1610: standard error:
    go_test.go:1610: go install go-cmd-test: mkdir /usr/local/google/home/bcmills/go/src/cmd/go/testdata/bin1/: permission denied

    go_test.go:1610: go [install go-cmd-test] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestInstallToCurrentDirectoryCreatesExecutable (0.14s)
    go_test.go:1623: running testgo [install]
    go_test.go:1623: standard error:
    go_test.go:1623: go install go-cmd-test: open /usr/local/google/home/bcmills/go/src/cmd/go/testdata/src/go-cmd-test/go-cmd-test: permission denied

    go_test.go:1623: go [install] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go/testdata/src/go-cmd-test: exit status 1
    panic.go:416: ended in /usr/local/google/home/bcmills/go/src/cmd/go/testdata/src/go-cmd-test
--- FAIL: TestInstallToGOBINCommandLinePackage (0.19s)
    go_test.go:1643: running testgo [install testdata/src/go-cmd-test/helloworld.go]
    go_test.go:1643: standard error:
    go_test.go:1643: go install command-line-arguments: mkdir /usr/local/google/home/bcmills/go/src/cmd/go/testdata/bin1/: permission denied

    go_test.go:1643: go [install testdata/src/go-cmd-test/helloworld.go] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestIgnoreEmptyPathsInGOPATH (0.17s)
    go_test.go:1758: running testgo [install go-cmd-test]
    go_test.go:1758: standard error:
    go_test.go:1758: go install go-cmd-test: open /usr/local/google/home/bcmills/go/src/cmd/go/testdata/bin/go-cmd-test: permission denied

    go_test.go:1758: go [install go-cmd-test] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
--- FAIL: TestUserOverrideFlags (0.87s)
    go_test.go:4817: running testgo [build -x -buildmode=c-archive -gcflags=all=-shared=false /tmp/cmd-go-test-724323648/gotest428768554/override.go]
    go_test.go:4817: standard error:
    go_test.go:4817: WORK=/tmp/cmd-go-test-724323648/go-build317154046
        mkdir -p $WORK/b003/
        cd /usr/local/google/home/bcmills/go/src/runtime/cgo
        CGO_LDFLAGS='"-g" "-O2" "-lpthread"' /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b003/ -importpath runtime/cgo -import_runtime_cgo=false -import_syscall=false -exportheader=$WORK/b003/_cgo_install.h -- -I $WORK/b003/ -g -O2 -Wall -Werror ./cgo.go
        cd $WORK
        gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
        gcc -Qunused-arguments -c -x c - -o /dev/null || true
        gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
        gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
        cd $WORK/b003
        TERM='dumb' gcc -I /usr/local/google/home/bcmills/go/src/runtime/cgo -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -Wall -Werror -o ./_x001.o -c _cgo_export.c
        TERM='dumb' gcc -I /usr/local/google/home/bcmills/go/src/runtime/cgo -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -Wall -Werror -o ./_x002.o -c cgo.cgo2.c
        cd /usr/local/google/home/bcmills/go/src/runtime/cgo
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x003.o -c gcc_context.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x004.o -c gcc_fatalf.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x005.o -c gcc_libinit.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x006.o -c gcc_linux_amd64.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x007.o -c gcc_mmap.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x008.o -c gcc_setenv.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x009.o -c gcc_sigaction.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x010.o -c gcc_traceback.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x011.o -c gcc_util.c
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I $WORK/b003/ -g -O2 -Wall -Werror -o $WORK/b003/_x012.o -c gcc_amd64.S
        cd $WORK/b003
        TERM='dumb' gcc -I /usr/local/google/home/bcmills/go/src/runtime/cgo -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -Wall -Werror -o ./_cgo_main.o -c _cgo_main.c
        cd /usr/local/google/home/bcmills/go/src/runtime/cgo
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b003=/tmp/go-build -gno-record-gcc-switches -o $WORK/b003/_cgo_.o $WORK/b003/_cgo_main.o $WORK/b003/_x001.o $WORK/b003/_x002.o $WORK/b003/_x003.o $WORK/b003/_x004.o $WORK/b003/_x005.o $WORK/b003/_x006.o $WORK/b003/_x007.o $WORK/b003/_x008.o $WORK/b003/_x009.o $WORK/b003/_x010.o $WORK/b003/_x011.o $WORK/b003/_x012.o -g -O2 -lpthread
        TERM='dumb' /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/cgo -dynpackage cgo -dynimport $WORK/b003/_cgo_.o -dynout $WORK/b003/_cgo_import.go -dynlinker
        mkdir -p $WORK/b001/
        cd /tmp/cmd-go-test-724323648/gotest428768554
        CGO_LDFLAGS='"-g" "-O2"' /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b001/ -importpath command-line-arguments -exportheader=$WORK/b001/_cgo_install.h -- -I $WORK/b001/ -g -O2 ./override.go
        cd $WORK/b001
        TERM='dumb' gcc -I /tmp/cmd-go-test-724323648/gotest428768554 -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -o ./_x001.o -c _cgo_export.c
        TERM='dumb' gcc -I /tmp/cmd-go-test-724323648/gotest428768554 -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -o ./_x002.o -c override.cgo2.c
        TERM='dumb' gcc -I /tmp/cmd-go-test-724323648/gotest428768554 -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -o ./_cgo_main.o -c _cgo_main.c
        cd /tmp/cmd-go-test-724323648/gotest428768554
        TERM='dumb' gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o $WORK/b001/_x002.o -g -O2
        TERM='dumb' /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/cgo -dynpackage main -dynimport $WORK/b001/_cgo_.o -dynout $WORK/b001/_cgo_import.go
        cat >$WORK/b001/importcfg << 'EOF' # internal
        # import config
        packagefile runtime/cgo=/usr/local/google/home/bcmills/go/pkg/obj/go-build/ad/adee375b87454d36f3a964fb5dfc41945c3c11008e3db936dd4bdfec1738ac24-d
        packagefile syscall=/usr/local/google/home/bcmills/go/pkg/obj/go-build/f6/f6339c2977ee6281a86140544a5028562daa177380e5ca3c343e57d92cde8cd9-d
        packagefile runtime=/usr/local/google/home/bcmills/go/pkg/obj/go-build/c8/c8607ff58ce59801aa276b053cb97c9a614c262d46dae8aea4db8476d6f60e69-d
        EOF
        /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/compile -o $WORK/b001/_pkg_.a -trimpath $WORK/b001 -shared -shared=false -p main -installsuffix shared -buildid EgnKmsSnGpUkYSuiMNtZ/EgnKmsSnGpUkYSuiMNtZ -D _/tmp/cmd-go-test-724323648/gotest428768554 -importcfg $WORK/b001/importcfg -pack $WORK/b001/_cgo_gotypes.go $WORK/b001/override.cgo1.go $WORK/b001/_cgo_import.go
        /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/pack r $WORK/b001/_pkg_.a $WORK/b001/_x001.o $WORK/b001/_x002.o # internal
        /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/_pkg_.a # internal
        cp $WORK/b001/_pkg_.a /usr/local/google/home/bcmills/go/pkg/obj/go-build/e7/e766c32892df57d7a75d8a09203d0681f50d66372b7b85ad43fe81499e69e374-d # internal
        cat >$WORK/b001/importcfg.link << 'EOF' # internal
        packagefile command-line-arguments=$WORK/b001/_pkg_.a
        packagefile runtime/cgo=/usr/local/google/home/bcmills/go/pkg/obj/go-build/ad/adee375b87454d36f3a964fb5dfc41945c3c11008e3db936dd4bdfec1738ac24-d
        packagefile syscall=/usr/local/google/home/bcmills/go/pkg/obj/go-build/f6/f6339c2977ee6281a86140544a5028562daa177380e5ca3c343e57d92cde8cd9-d
        packagefile runtime=/usr/local/google/home/bcmills/go/pkg/obj/go-build/c8/c8607ff58ce59801aa276b053cb97c9a614c262d46dae8aea4db8476d6f60e69-d
        packagefile internal/bytealg=/usr/local/google/home/bcmills/go/pkg/obj/go-build/c1/c1311a0a30d0a2e126f9c24cfce7787170ad78c8cd03d6fd664ed8db59cd34a6-d
        packagefile internal/race=/usr/local/google/home/bcmills/go/pkg/obj/go-build/5d/5d7ac0730103352dea8188242218a9543e4287666a6f129ef6197229c67b3264-d
        packagefile sync=/usr/local/google/home/bcmills/go/pkg/obj/go-build/0c/0c3bfa8a5d7e2b6b089b347f6c8e8124a62307ce56f7d969434f7abf87fb7106-d
        packagefile internal/cpu=/usr/local/google/home/bcmills/go/pkg/obj/go-build/57/57b38572974a8d6f9eb7dd98757170e9baaf3ac2598b1feee94764994fa14791-d
        packagefile runtime/internal/atomic=/usr/local/google/home/bcmills/go/pkg/obj/go-build/67/6707c09846c0c071b3be5f98e6713e24f4bd3ff5547c071a2f05918f0fd7d667-d
        packagefile runtime/internal/math=/usr/local/google/home/bcmills/go/pkg/obj/go-build/ac/ac88a02dd292fd1f204ca0ccbbee83a55fcd2c2453ce3482e4fe9c955da7daf4-d
        packagefile runtime/internal/sys=/usr/local/google/home/bcmills/go/pkg/obj/go-build/e4/e4b914406e51b7c38506993637347ce0b05740f9d88c9ed04cca5abd9733e167-d
        packagefile sync/atomic=/usr/local/google/home/bcmills/go/pkg/obj/go-build/ed/ed1170d402fa5e53e4da7c4e976d7911624abf451d1dca09e2a06d95040bbf72-d
        EOF
        mkdir -p $WORK/b001/exe/
        cd .
        /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out.a -importcfg $WORK/b001/importcfg.link -installsuffix shared -buildmode=c-archive -buildid=ggsSXRsDUjXKHaPHnZ4Q/EgnKmsSnGpUkYSuiMNtZ/NKrpcS2PQRm7i22G-C7T/ggsSXRsDUjXKHaPHnZ4Q -extld=gcc $WORK/b001/_pkg_.a
        /usr/local/google/home/bcmills/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/exe/a.out.a # internal
        cp $WORK/b001/_cgo_install.h override.h
        open override.h: permission denied

    go_test.go:4817: go [build -x -buildmode=c-archive -gcflags=all=-shared=false /tmp/cmd-go-test-724323648/gotest428768554/override.go] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
go test proxy starting
go proxy_test: invalid module path encoding "example.com/invalidpath/v1": malformed module path "example.com/invalidpath/v1": invalid version
go test proxy running at GOPROXY=http://127.0.0.1:34413/mod
go proxy: no archive rsc.io v1.5.0
go proxy: no archive example.com/split/subpkg v1.0.0
go proxy: no archive golang.org/x/text/language 14c0d48
go proxy: no archive golang.org/x/text/language 14c0d48
go proxy: no archive golang.org/x/text/language 14c0d48
go proxy: no archive golang.org/x/text/foo 14c0d48
go proxy: no archive golang.org/x 14c0d48
go proxy: no archive golang.org 14c0d48
go proxy: no archive this.domain.is.invalid/somemodule v1.0.0
go proxy: no archive this.domain.is.invalid/somemodule v1.0.0
go proxy: no archive rsc.io/quote v1.99999999.0-not-a-real-version
--- FAIL: TestLinkXImportPathEscape (0.19s)
    go_test.go:4509: running testgo [build -o ./linkx -ldflags -X=my.pkg.Text=linkXworked my.pkg/main]
    go_test.go:4509: standard error:
    go_test.go:4509: go build my.pkg/main: open ./linkx: permission denied

    go_test.go:4509: go [build -o ./linkx -ldflags -X=my.pkg.Text=linkXworked my.pkg/main] failed unexpectedly in /usr/local/google/home/bcmills/go/src/cmd/go: exit status 1
FAIL
FAIL    cmd/go  32.900s
@gopherbot

This comment has been minimized.

Copy link

commented Jun 10, 2019

Change https://golang.org/cl/181541 mentions this issue: cmd/go: factor the I/O-retry logic out of renameio

gopherbot pushed a commit that referenced this issue Jun 13, 2019
cmd/go: factor the I/O-retry logic out of renameio
Factor the try-on-failure variants are now in the package
cmd/go/internal/robustio.

Add to them a RemoveAll variant using the same retry loop,
and use it to attempt to address the observed flakes in
TestLinkXImportPathEscape.

Fixes #19491
Updates #25965
Updates #28387
Updates #32188

Change-Id: I9db1a0c7537b8aaadccab1b9eca734595668ba29
Reviewed-on: https://go-review.googlesource.com/c/go/+/181541
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Aug 30, 2019

Change https://golang.org/cl/192577 mentions this issue: all: do not write to testdata directories

gopherbot pushed a commit to golang/tools that referenced this issue Aug 30, 2019
all: do not write to testdata directories
I got tired of spurious 'git' diffs while a 'go test' was running, so
I fixed the test that produced the diffs. (We need to do that anyway
in order to run them in the module cache, plus it's just good hygiene
not to have tests interfering with each other's sources.)

Tested using:

	$ chmod -R ugo-w . && go test ./...; chmod -R u+w .

Updates golang/go#28387

Change-Id: Ie17e31aecf0e3cb022df5503d7c443000366a5c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192577
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.