From 5e41fe0e45c66bf7359988551a321137e2ddfe89 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 5 Mar 2012 22:47:23 -0500 Subject: [PATCH] build: use run.go for running tests Also, tweak run.go to use no more than 2x the number of CPUs, and only one on ARM. 53.85u 13.33s 53.69r ./run 50.68u 12.13s 18.85r go run run.go Fixes #2833. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5754047 --- src/run.bash | 2 +- src/run.bat | 9 ++++++++- test/run.go | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/run.bash b/src/run.bash index fdbf47663b..7b1854865e 100755 --- a/src/run.bash +++ b/src/run.bash @@ -105,7 +105,7 @@ $BROKEN || ) || exit $? (xcd ../test -./run +time go run run.go ) || exit $? echo diff --git a/src/run.bat b/src/run.bat index 9f2af3978b..f1eebe374a 100644 --- a/src/run.bat +++ b/src/run.bat @@ -36,7 +36,14 @@ go test sync -short -timeout=120s -cpu=10 if errorlevel 1 goto fail echo. -:: TODO: The other tests in run.bash, especially $GOROOT/test/run. +:: TODO: The other tests in run.bash. + +echo # test +cd test +go run run.go +cd .. +if errorlevel 1 goto fail +echo. echo ALL TESTS PASSED goto end diff --git a/test/run.go b/test/run.go index 050cfadb2c..f0b2555db0 100644 --- a/test/run.go +++ b/test/run.go @@ -30,7 +30,7 @@ import ( var ( verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.") - numParallel = flag.Int("n", 8, "number of parallel tests to run") + numParallel = flag.Int("n", 2*runtime.NumCPU(), "number of parallel tests to run") summary = flag.Bool("summary", false, "show summary of results") showSkips = flag.Bool("show_skips", false, "show skipped tests") ) @@ -60,7 +60,10 @@ const maxTests = 5000 func main() { flag.Parse() - if *verbose { + + // Disable parallelism if printing, or if running on + // (presumably underpowered) arm systems. + if *verbose || runtime.GOARCH == "arm" { *numParallel = 1 }