]> Cypherpunks repositories - gostls13.git/commitdiff
testing: set up structure for faster testing using the new -test.short flag.
authorRob Pike <r@golang.org>
Fri, 25 Mar 2011 21:50:44 +0000 (14:50 -0700)
committerRob Pike <r@golang.org>
Fri, 25 Mar 2011 21:50:44 +0000 (14:50 -0700)
New make target "testshort" runs "gotest -test.short" and is invoked
by run.bash, which is invoked by all.bash.

Use -test.short to make one package (crypto ecdsa) run much faster.
More changes to come.

Once this is in, I will update the long-running tests to use the new flag.

R=rsc
CC=golang-dev
https://golang.org/cl/4317043

src/Make.pkg
src/cmd/gofix/Makefile
src/cmd/goinstall/Makefile
src/cmd/gotest/doc.go
src/cmd/gotype/Makefile
src/pkg/Makefile
src/pkg/crypto/ecdsa/ecdsa_test.go
src/pkg/testing/testing.go
src/run.bash

index d8d034dfa3a230695b537900207454d3d75117c1..8eadb111cac32d312061b4d258593e7245b6caa4 100644 (file)
@@ -60,6 +60,9 @@ CLEANFILES+=*.so _obj _test _testmain.go *.exe _cgo* *.cgo[12].*
 test:
        gotest
 
+testshort:
+       gotest -test.short
+
 bench:
        gotest -test.bench=. -test.run="Do not run tests"
 
index 9383f5ac641d01fac68d0fc96261e9d60abda2cd..4143e0cbe116156d0853b07aa92e4db8f68c791e 100644 (file)
@@ -15,3 +15,6 @@ include ../../Make.cmd
 
 test:
        gotest
+
+testshort:
+       gotest -test.short
index 6900bcb61d24198fa201458d39f7ef95bdce1a13..aaf202ee794b69b4b5025e6028bc4b22a64ac8d8 100644 (file)
@@ -24,3 +24,6 @@ syslist.go:
 
 test:
        gotest
+
+testshort:
+       gotest -test.short
index 04e426bab3923eda1b37611356a07b2d0e80e868..015622c8171057e2112535f17b4f48cab1f82ec1 100644 (file)
@@ -66,5 +66,9 @@ the environment variable GOGC=off to disable the garbage collector,
 provided the test can run in the available memory without garbage
 collection.
 
+The -test.short package tells long-running tests to shorten their
+run time. It is off by default but set by all.bash so installations
+of the Go tree can do a sanity check but not spend time running the
+full test suite.
 */
 package documentation
index 929fc52de1e2986e174555ba6792bb92c94c6a9e..18171945dfe9658dde878e6a0c6710d4209d3113 100644 (file)
@@ -12,3 +12,6 @@ include ../../Make.cmd
 
 test:
        gotest
+
+testshort:
+       gotest -test.short
index 3a2a479f5e1a23d90588fc8dbeb74ce91704615a..51300c0880abe613031c39f2bc18f10f1b3f1fc8 100644 (file)
@@ -222,6 +222,7 @@ clean.dirs: $(addsuffix .clean, $(DIRS))
 install.dirs: $(addsuffix .install, $(DIRS))
 nuke.dirs: $(addsuffix .nuke, $(DIRS))
 test.dirs: $(addsuffix .test, $(TEST))
+testshort.dirs: $(addsuffix .testshort, $(TEST))
 bench.dirs: $(addsuffix .bench, $(BENCH))
 
 %.clean:
@@ -236,6 +237,9 @@ bench.dirs: $(addsuffix .bench, $(BENCH))
 %.test:
        +$(MAKE) -C $* test
 
+%.testshort:
+       +$(MAKE) -C $* testshort
+
 %.bench:
        +$(MAKE) -C $* bench    
 
@@ -245,6 +249,8 @@ install: install.dirs
 
 test:  test.dirs
 
+testshort: testshort.dirs
+
 bench: bench.dirs ../../test/garbage.bench
 
 nuke: nuke.dirs
index cc22b7a52f1ae8b34e3a8c8cbd008ee90f60d9ce..24c1d735bddfd63dbf9489ac1e742c0e85eab61f 100644 (file)
@@ -26,6 +26,9 @@ func testKeyGeneration(t *testing.T, c *elliptic.Curve, tag string) {
 
 func TestKeyGeneration(t *testing.T) {
        testKeyGeneration(t, elliptic.P224(), "p224")
+       if testing.Short() {
+               return
+       }
        testKeyGeneration(t, elliptic.P256(), "p256")
        testKeyGeneration(t, elliptic.P384(), "p384")
        testKeyGeneration(t, elliptic.P521(), "p521")
@@ -53,6 +56,9 @@ func testSignAndVerify(t *testing.T, c *elliptic.Curve, tag string) {
 
 func TestSignAndVerify(t *testing.T) {
        testSignAndVerify(t, elliptic.P224(), "p224")
+       if testing.Short() {
+               return
+       }
        testSignAndVerify(t, elliptic.P256(), "p256")
        testSignAndVerify(t, elliptic.P384(), "p384")
        testSignAndVerify(t, elliptic.P521(), "p521")
@@ -214,5 +220,8 @@ func TestVectors(t *testing.T) {
                if Verify(&pub, hashed, r, s) != test.ok {
                        t.Errorf("%d: bad result", i)
                }
+               if testing.Short() {
+                       break
+               }
        }
 }
index ab8cf999a2564dd6c3d7c0b4f74f79bc60218e5c..cdc98262902e3248f9250c0fa0cbeaf103909083 100644 (file)
@@ -48,6 +48,13 @@ import (
 )
 
 var (
+       // The short flag requests that tests run more quickly, but its functionality
+       // is provided by test writers themselves.  The testing package is just its
+       // home.  The all.bash installation script sets it to make installation more
+       // efficient, but by default the flag is off so a plain "gotest" will do a
+       // full test of the package.
+       short = flag.Bool("test.short", false, "run smaller test suite to save time")
+
        // Report as tests are run; default is silent for success.
        chatty         = flag.Bool("test.v", false, "verbose: print additional output")
        match          = flag.String("test.run", "", "regular expression to select tests to run")
@@ -56,6 +63,11 @@ var (
        cpuProfile     = flag.String("test.cpuprofile", "", "write a cpu profile to the named file during execution")
 )
 
+// Short reports whether the -test.short flag is set.
+func Short() bool {
+       return *short
+}
+
 
 // Insert final newline if needed and tabs after internal newlines.
 func tabify(s string) string {
index be90af0da68b01bc090478e4486d02962887a571..dd80d3ab643a3da4fb9205d70fe8c6850a41e194 100755 (executable)
@@ -39,7 +39,7 @@ if $rebuild; then
 fi
 
 (xcd pkg
-gomake test
+gomake testshort
 ) || exit $?
 
 (xcd pkg/sync;
@@ -47,7 +47,7 @@ if $rebuild; then
        gomake clean;
        time gomake
 fi
-GOMAXPROCS=10 gomake test
+GOMAXPROCS=10 gomake testshort
 ) || exit $?
 
 [ "$GOARCH" == arm ] ||