mirror of https://github.com/golang/go.git
cmd/link: write output in temp dir in TestUnlinkableObj
For unlinkable object the link will fail, but it opens the output file in writable mode first then delete it on failure. This fails if the current directory is not writable. Write to the temporary directory instead. Change-Id: Iefd73b5cc8efdc0f11b12edc0920169a8ad3f37c Reviewed-on: https://go-review.googlesource.com/c/go/+/394755 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
946167906e
commit
ac3efc83e6
|
|
@ -1069,6 +1069,7 @@ func TestUnlinkableObj(t *testing.T) {
|
|||
|
||||
src := filepath.Join(tmpdir, "x.go")
|
||||
obj := filepath.Join(tmpdir, "x.o")
|
||||
exe := filepath.Join(tmpdir, "x.exe")
|
||||
err := ioutil.WriteFile(src, []byte("package main\nfunc main() {}\n"), 0666)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to write source file: %v", err)
|
||||
|
|
@ -1078,7 +1079,7 @@ func TestUnlinkableObj(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("compile failed: %v. output:\n%s", err, out)
|
||||
}
|
||||
cmd = exec.Command(testenv.GoToolPath(t), "tool", "link", obj)
|
||||
cmd = exec.Command(testenv.GoToolPath(t), "tool", "link", "-o", exe, obj)
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
t.Fatalf("link did not fail")
|
||||
|
|
|
|||
Loading…
Reference in New Issue