]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: run commands in $GOROOT/src not $GOROOT when possible
authorRuss Cox <rsc@golang.org>
Fri, 17 Apr 2015 19:20:27 +0000 (15:20 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 20 Apr 2015 19:54:01 +0000 (19:54 +0000)
The go command prints paths in errors relative to its current directory.
Since all.bash and run.bash are run in $GOROOT/src, prefer to run
the go command, so that the relative paths are correct.

Before this CL, running all.bash in $GOROOT/src:

##### Testing race detector
# net/http
src/net/http/transport.go:1257: cannot take the address of <node EFACE>

This is wrong (or at least less useful) because there is no $GOROOT/src/src/net/http directory.

Change-Id: I0c0d52c22830d79b3715f51a6329a3d33de52a72
Reviewed-on: https://go-review.googlesource.com/9157
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/dist/test.go

index 4a6688b8f6cfd1d1f1d97051fe91ffd37ac7a1cc..f4fef5655d2439999060e4b0c32509a56c5170d0 100644 (file)
@@ -200,7 +200,7 @@ func (t *tester) registerTests() {
                        name:    testName,
                        heading: "GOMAXPROCS=2 runtime -cpu=1,2,4",
                        fn: func() error {
-                               cmd := t.dirCmd(".", "go", "test", "-short", t.timeout(300), "runtime", "-cpu="+cpu)
+                               cmd := t.dirCmd("src", "go", "test", "-short", t.timeout(300), "runtime", "-cpu="+cpu)
                                // We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
                                // creation of first goroutines and first garbage collections in the parallel setting.
                                cmd.Env = mergeEnvLists([]string{"GOMAXPROCS=2"}, os.Environ())
@@ -214,7 +214,7 @@ func (t *tester) registerTests() {
                name:    "sync_cpu",
                heading: "sync -cpu=10",
                fn: func() error {
-                       return t.dirCmd(".", "go", "test", "sync", "-short", t.timeout(120), "-cpu=10").Run()
+                       return t.dirCmd("src", "go", "test", "sync", "-short", t.timeout(120), "-cpu=10").Run()
                },
        })
 
@@ -309,7 +309,7 @@ func (t *tester) registerTests() {
                        name:    "api",
                        heading: "API check",
                        fn: func() error {
-                               return t.dirCmd(".", "go", "run", filepath.Join(t.goroot, "src/cmd/api/run.go")).Run()
+                               return t.dirCmd("src", "go", "run", filepath.Join(t.goroot, "src/cmd/api/run.go")).Run()
                        },
                })
        }
@@ -573,18 +573,18 @@ func (t *tester) raceDetectorSupported() bool {
 }
 
 func (t *tester) raceTest() error {
-       if err := t.dirCmd(".", "go", "test", "-race", "-i", "runtime/race", "flag", "os/exec").Run(); err != nil {
+       if err := t.dirCmd("src", "go", "test", "-race", "-i", "runtime/race", "flag", "os/exec").Run(); err != nil {
                return err
        }
-       if err := t.dirCmd(".", "go", "test", "-race", "-run=Output", "runtime/race").Run(); err != nil {
+       if err := t.dirCmd("src", "go", "test", "-race", "-run=Output", "runtime/race").Run(); err != nil {
                return err
        }
-       if err := t.dirCmd(".", "go", "test", "-race", "-short", "flag", "os/exec").Run(); err != nil {
+       if err := t.dirCmd("src", "go", "test", "-race", "-short", "flag", "os/exec").Run(); err != nil {
                return err
        }
        if t.extLink() {
                // Test with external linking; see issue 9133.
-               if err := t.dirCmd(".", "go", "test", "-race", "-short", "-ldflags=-linkmode=external", "flag", "os/exec").Run(); err != nil {
+               if err := t.dirCmd("src", "go", "test", "-race", "-short", "-ldflags=-linkmode=external", "flag", "os/exec").Run(); err != nil {
                        return err
                }
        }