]> Cypherpunks repositories - gostls13.git/commitdiff
test/fixedbugs: fix some tests will not be run
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>
Fri, 17 May 2019 10:25:07 +0000 (17:25 +0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 23 May 2019 01:39:41 +0000 (01:39 +0000)
Currently, some tests under test/fixedbugs never run:

$ for d in test/fixedbugs/*.dir; do
  ! test -f "${d%.dir}.go" && echo "$d"
done
test/fixedbugs/issue15071.dir
test/fixedbugs/issue15609.dir
test/fixedbugs/issue29612.dir

Because they missed the corresponding ".go" file, so "go run run.go"
will skip them.

Add missing ".go" files for those tests to make sure they will be
collected and run.

While at it, add another action "runindir", which does "go run ."
inside the t.goDirName then check the output.

Change-Id: I88000b3663a6a615d90c1cf11844ea0377403e3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/177798
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
test/fixedbugs/issue15071.dir/exp.go [moved from test/fixedbugs/issue15071.dir/exp/exp.go with 100% similarity]
test/fixedbugs/issue15071.go [new file with mode: 0644]
test/fixedbugs/issue15609.go [new file with mode: 0644]
test/fixedbugs/issue29612.go [new file with mode: 0644]
test/run.go

diff --git a/test/fixedbugs/issue15071.go b/test/fixedbugs/issue15071.go
new file mode 100644 (file)
index 0000000..af6f134
--- /dev/null
@@ -0,0 +1,7 @@
+// rundir
+
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
diff --git a/test/fixedbugs/issue15609.go b/test/fixedbugs/issue15609.go
new file mode 100644 (file)
index 0000000..87c96b4
--- /dev/null
@@ -0,0 +1,7 @@
+// runindir
+
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
diff --git a/test/fixedbugs/issue29612.go b/test/fixedbugs/issue29612.go
new file mode 100644 (file)
index 0000000..87c96b4
--- /dev/null
@@ -0,0 +1,7 @@
+// runindir
+
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
index 84f5cd991c5d886cf600c36aca6ecbb2feccfa49..28ed865c50ffad42b75948fa4655e114f0b1dcb5 100644 (file)
@@ -522,7 +522,7 @@ func (t *test) run() {
 
        // TODO: Clean up/simplify this switch statement.
        switch action {
-       case "compile", "compiledir", "build", "builddir", "buildrundir", "run", "buildrun", "runoutput", "rundir", "asmcheck":
+       case "compile", "compiledir", "build", "builddir", "buildrundir", "run", "buildrun", "runoutput", "rundir", "runindir", "asmcheck":
                // nothing to do
        case "errorcheckandrundir":
                wantError = false // should be no error if also will run
@@ -603,16 +603,19 @@ func (t *test) run() {
        }
 
        useTmp := true
+       runInDir := false
        runcmd := func(args ...string) ([]byte, error) {
                cmd := exec.Command(args[0], args[1:]...)
                var buf bytes.Buffer
                cmd.Stdout = &buf
                cmd.Stderr = &buf
+               cmd.Env = os.Environ()
                if useTmp {
                        cmd.Dir = t.tempDir
                        cmd.Env = envForDir(cmd.Dir)
-               } else {
-                       cmd.Env = os.Environ()
+               }
+               if runInDir {
+                       cmd.Dir = t.goDirName()
                }
 
                var err error
@@ -834,6 +837,28 @@ func (t *test) run() {
                        }
                }
 
+       case "runindir":
+               // run "go run ." in t.goDirName()
+               // It's used when test requires go build and run the binary success.
+               // Example when long import path require (see issue29612.dir) or test
+               // contains assembly file (see issue15609.dir).
+               // Verify the expected output.
+               useTmp = false
+               runInDir = true
+               cmd := []string{goTool(), "run", goGcflags()}
+               if *linkshared {
+                       cmd = append(cmd, "-linkshared")
+               }
+               cmd = append(cmd, ".")
+               out, err := runcmd(cmd...)
+               if err != nil {
+                       t.err = err
+                       return
+               }
+               if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
+                       t.err = fmt.Errorf("incorrect output\n%s", out)
+               }
+
        case "build":
                // Build Go file.
                _, err := runcmd(goTool(), "build", goGcflags(), "-o", "a.exe", long)