flag.BoolVar(&noRebuild, "no-rebuild", false, "overrides -rebuild (historical dreg)")
flag.BoolVar(&t.keepGoing, "k", false, "keep going even when error occurred")
flag.BoolVar(&t.race, "race", false, "run in race builder mode (different set of tests)")
+ flag.BoolVar(&t.compileOnly, "compile-only", false, "compile tests, but don't run them. This is for some builders. Not all dist tests respect this flag, but most do.")
flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners")
flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"),
"run only those tests matching the regular expression; empty means to run all. "+
rebuild bool
failed bool
keepGoing bool
+ compileOnly bool // just try to compile all tests, but no need to run
runRxStr string
runRx *regexp.Regexp
runRxWant bool // want runRx to match (true) or not match (false)
if t.race {
args = append(args, "-race")
}
+ if t.compileOnly {
+ args = append(args, "-run=^$")
+ }
args = append(args, stdMatches...)
cmd := exec.Command("go", args...)
cmd.Stdout = os.Stdout
"-short",
"-race",
"-run=^$", // nothing. only benchmarks.
- "-bench=.*",
"-benchtime=.1s",
"-cpu=4",
}
+ if !t.compileOnly {
+ args = append(args, "-bench=.*")
+ }
args = append(args, benchMatches...)
cmd := exec.Command("go", args...)
cmd.Stdout = os.Stdout
}
// Runtime CPU tests.
- testName := "runtime:cpu124"
- t.tests = append(t.tests, distTest{
- name: testName,
- heading: "GOMAXPROCS=2 runtime -cpu=1,2,4",
- fn: func(dt *distTest) error {
- cmd := t.addCmd(dt, "src", "go", "test", "-short", t.timeout(300), t.tags(), "runtime", "-cpu=1,2,4")
- // 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())
- return nil
- },
- })
+ if !t.compileOnly {
+ testName := "runtime:cpu124"
+ t.tests = append(t.tests, distTest{
+ name: testName,
+ heading: "GOMAXPROCS=2 runtime -cpu=1,2,4",
+ fn: func(dt *distTest) error {
+ cmd := t.addCmd(dt, "src", "go", "test", "-short", t.timeout(300), t.tags(), "runtime", "-cpu=1,2,4")
+ // 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())
+ return nil
+ },
+ })
+ }
// Test that internal linking of standard packages does not
// require libgcc. This ensures that we can install a Go
name: "nolibgcc:" + pkg,
heading: "Testing without libgcc.",
fn: func(dt *distTest) error {
- t.addCmd(dt, "src", "go", "test", "-short", "-ldflags=-linkmode=internal -libgcc=none", t.tags(), pkg, "-run="+run)
+ t.addCmd(dt, "src", "go", "test", "-short", "-ldflags=-linkmode=internal -libgcc=none", t.tags(), pkg, t.runFlag(run))
return nil
},
})
name: "sync_cpu",
heading: "sync -cpu=10",
fn: func(dt *distTest) error {
- t.addCmd(dt, "src", "go", "test", "sync", "-short", t.timeout(120), t.tags(), "-cpu=10")
+ t.addCmd(dt, "src", "go", "test", "sync", "-short", t.timeout(120), t.tags(), "-cpu=10", t.runFlag(""))
return nil
},
})
}
if t.goos != "android" && !t.iOS() {
- t.registerTest("bench_go1", "../test/bench/go1", "go", "test", t.timeout(600))
+ t.registerTest("bench_go1", "../test/bench/go1", "go", "test", t.timeout(600), t.runFlag(""))
}
if t.goos != "android" && !t.iOS() {
const nShards = 5
name: "api",
heading: "API check",
fn: func(dt *distTest) error {
+ if t.compileOnly {
+ t.addCmd(dt, "src", "go", "build", filepath.Join(t.goroot, "src/cmd/api/run.go"))
+ return nil
+ }
t.addCmd(dt, "src", "go", "run", filepath.Join(t.goroot, "src/cmd/api/run.go"))
return nil
},
return cmd.Run()
}
- cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", t.tags(), "-ldflags", "-linkmode=auto")
+ cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", t.tags(), "-ldflags", "-linkmode=auto", t.runFlag(""))
cmd.Env = env
if t.gohostos != "dragonfly" && t.gohostarch != "ppc64le" {
// linkmode=internal fails on dragonfly since errno is a TLS relocation.
// linkmode=internal fails on ppc64le because cmd/link doesn't
// handle the TOC correctly (issue 15409).
- cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", "-ldflags", "-linkmode=internal")
+ cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", "-ldflags", "-linkmode=internal", t.runFlag(""))
cmd.Env = env
}
return false
}
+func (t *tester) runFlag(rx string) string {
+ if t.compileOnly {
+ return "-run=^$"
+ }
+ return "-run=" + rx
+}
+
func (t *tester) raceTest(dt *distTest) error {
t.addCmd(dt, "src", "go", "test", "-race", "-i", "runtime/race", "flag", "os/exec")
- t.addCmd(dt, "src", "go", "test", "-race", "-run=Output", "runtime/race")
- t.addCmd(dt, "src", "go", "test", "-race", "-short", "-run=TestParse|TestEcho", "flag", "os/exec")
+ t.addCmd(dt, "src", "go", "test", "-race", t.runFlag("Output"), "runtime/race")
+ t.addCmd(dt, "src", "go", "test", "-race", "-short", t.runFlag("TestParse|TestEcho"), "flag", "os/exec")
// We don't want the following line, because it
// slows down all.bash (by 10 seconds on my laptop).
// The race builder should catch any error here, but doesn't.
// t.addCmd(dt, "src", "go", "test", "-race", "-run=TestParallelTest", "cmd/go")
if t.cgoEnabled {
env := mergeEnvLists([]string{"GOTRACEBACK=2"}, os.Environ())
- cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", "-race", "-short")
+ cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", "-race", "-short", t.runFlag(""))
cmd.Env = env
}
if t.extLink() {
// Test with external linking; see issue 9133.
- t.addCmd(dt, "src", "go", "test", "-race", "-short", "-ldflags=-linkmode=external", "-run=TestParse|TestEcho", "flag", "os/exec")
+ t.addCmd(dt, "src", "go", "test", "-race", "-short", "-ldflags=-linkmode=external", t.runFlag("TestParse|TestEcho"), "flag", "os/exec")
}
return nil
}
if runtest.err != nil {
return runtest.err
}
-
+ if t.compileOnly {
+ return nil
+ }
t.addCmd(dt, "test", runtest.exe,
fmt.Sprintf("--shard=%d", shard),
fmt.Sprintf("--shards=%d", shards),