Commit 273f4497 authored by Mostyn Bramley-Moore's avatar Mostyn Bramley-Moore Committed by Ian Lance Taylor

cmd/go/internal/work: clean up after TestRespectGroupSticky

Use our own tempdir, to avoid having to Init (and somehow teardown)
Builder.  This way we don't leave behind any temp files.

Also, don't create a hardcoded path inside a testcase.

Followup to golang/go#18878.
Fixes golang/go#19449.

Change-Id: Ieb1ebeab24ae8a74a6fa058d9c23f72b3fc1c444
Reviewed-on: https://go-review.googlesource.com/40912Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent eed6938c
......@@ -9,7 +9,6 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"runtime"
......@@ -181,7 +180,6 @@ func TestRespectGroupSticky(t *testing.T) {
}
var b Builder
b.Init()
// Check that `cp` is called instead of `mv` by looking at the output
// of `(*Builder).ShowCmd` afterwards as a sanity check.
......@@ -191,21 +189,20 @@ func TestRespectGroupSticky(t *testing.T) {
return cmdBuf.WriteString(fmt.Sprint(a...))
}
stickydir := path.Join(os.TempDir(), "GroupSticky")
if err := os.Mkdir(stickydir, 0755); err != nil {
stickydir, err := ioutil.TempDir("", "GroupSticky")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(stickydir)
// Mkdir doesn't always correctly set the group sticky bit.
// Change stickydir's permissions to include group sticky bit.
if err := os.Chmod(stickydir, 0755|os.ModeSetgid); err != nil {
t.Fatal(err)
}
pkgfile, err := ioutil.TempFile(b.WorkDir, "")
pkgfile, err := ioutil.TempFile("", "pkgfile")
if err != nil {
t.Fatalf("ioutil.TempFile(%q): %v", b.WorkDir, err)
t.Fatalf("ioutil.TempFile(\"\", \"pkgfile\"): %v", err)
}
defer os.Remove(pkgfile.Name())
defer pkgfile.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment