Commit 8ea27e11 authored by Bryan C. Mills's avatar Bryan C. Mills

misc/cgo/errors: fix tests in module mode

Updates #30228

Change-Id: I84bc705591bdb3da0106404b24353251939355b8
Reviewed-on: https://go-review.googlesource.com/c/163209Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent b35dacaa
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
) )
func path(file string) string { func path(file string) string {
return filepath.Join("src", file) return filepath.Join("testdata", file)
} }
func check(t *testing.T, file string) { func check(t *testing.T, file string) {
......
...@@ -444,8 +444,8 @@ func testOne(t *testing.T, pt ptrTest) { ...@@ -444,8 +444,8 @@ func testOne(t *testing.T, pt ptrTest) {
} }
defer os.RemoveAll(gopath) defer os.RemoveAll(gopath)
src := filepath.Join(gopath, "src") src := filepath.Join(gopath, "src", "ptrtest")
if err := os.Mkdir(src, 0777); err != nil { if err := os.MkdirAll(src, 0777); err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -490,6 +490,11 @@ func testOne(t *testing.T, pt ptrTest) { ...@@ -490,6 +490,11 @@ func testOne(t *testing.T, pt ptrTest) {
} }
} }
gomod := fmt.Sprintf("module %s\n", filepath.Base(src))
if err := ioutil.WriteFile(filepath.Join(src, "go.mod"), []byte(gomod), 0666); err != nil {
t.Fatalf("writing go.mod: %v", err)
}
args := func(cmd *exec.Cmd) string { args := func(cmd *exec.Cmd) string {
return strings.Join(cmd.Args, " ") return strings.Join(cmd.Args, " ")
} }
......
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