Commit 594a6bde authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

cmd/dist: add support for disabling test -short mode

So we can have builders running go test -short=false.

Updates golang/go#12508

Change-Id: If90f0f6d9f89268c33b1d1876139ad551fecd3d8
Reviewed-on: https://go-review.googlesource.com/113435Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent ca336483
...@@ -234,12 +234,32 @@ func (t *tester) shouldRunTest(name string) bool { ...@@ -234,12 +234,32 @@ func (t *tester) shouldRunTest(name string) bool {
return false return false
} }
// short returns a -short flag to pass to 'go test'.
// It returns "-short", unless the environment variable
// GO_TEST_SHORT is set to a non-empty, false-ish string.
//
// This environment variable is meant to be an internal
// detail between the Go build system and cmd/dist
// and is not intended for use by users.
func short() string {
if v := os.Getenv("GO_TEST_SHORT"); v != "" {
short, err := strconv.ParseBool(v)
if err != nil {
log.Fatalf("invalid GO_TEST_SHORT %q: %v", v, err)
}
if !short {
return "-short=false"
}
}
return "-short"
}
// goTest returns the beginning of the go test command line. // goTest returns the beginning of the go test command line.
// Callers should use goTest and then pass flags overriding these // Callers should use goTest and then pass flags overriding these
// defaults as later arguments in the command line. // defaults as later arguments in the command line.
func (t *tester) goTest() []string { func (t *tester) goTest() []string {
return []string{ return []string{
"go", "test", "-short", "-count=1", t.tags(), t.runFlag(""), "go", "test", short(), "-count=1", t.tags(), t.runFlag(""),
} }
} }
...@@ -295,7 +315,7 @@ func (t *tester) registerStdTest(pkg string) { ...@@ -295,7 +315,7 @@ func (t *tester) registerStdTest(pkg string) {
args := []string{ args := []string{
"test", "test",
"-short", short(),
t.tags(), t.tags(),
t.timeout(timeoutSec), t.timeout(timeoutSec),
"-gcflags=all=" + gogcflags, "-gcflags=all=" + gogcflags,
...@@ -333,7 +353,7 @@ func (t *tester) registerRaceBenchTest(pkg string) { ...@@ -333,7 +353,7 @@ func (t *tester) registerRaceBenchTest(pkg string) {
ranGoBench = true ranGoBench = true
args := []string{ args := []string{
"test", "test",
"-short", short(),
"-race", "-race",
"-run=^$", // nothing. only benchmarks. "-run=^$", // nothing. only benchmarks.
"-benchtime=.1s", "-benchtime=.1s",
......
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