test/fixedbugs: fix some tests will not be run

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>
This commit is contained in:
LE Manh Cuong 2019-05-17 17:25:07 +07:00 committed by Ian Lance Taylor
parent 7a567a631f
commit 3e9d8e2e1b
5 changed files with 49 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View 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)