]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: move exhaustive tests behind -long flag
authorRuss Cox <rsc@golang.org>
Mon, 10 Oct 2016 20:44:53 +0000 (16:44 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 11 Oct 2016 16:15:12 +0000 (16:15 +0000)
This way you can still run 'go test' or 'go bench -run Foo'
without wondering why it is taking so very long.

Change-Id: Icfa097a6deb1d6682acb7be9f34729215c29eabb
Reviewed-on: https://go-review.googlesource.com/30707
Reviewed-by: Robert Griesemer <gri@golang.org>
src/math/big/float_test.go
src/math/big/rat_test.go
src/math/big/ratconv_test.go

index bea5ac175cec14da94d553ed1538c8a14aa53053..7d4bd312c9bd45f47026a2346709023d37ed8397 100644 (file)
@@ -5,6 +5,7 @@
 package big
 
 import (
+       "flag"
        "fmt"
        "math"
        "strconv"
@@ -1495,12 +1496,14 @@ func TestFloatQuo(t *testing.T) {
        }
 }
 
+var long = flag.Bool("long", false, "run very long tests")
+
 // TestFloatQuoSmoke tests all divisions x/y for values x, y in the range [-n, +n];
 // it serves as a smoke test for basic correctness of division.
 func TestFloatQuoSmoke(t *testing.T) {
-       n := 1000
-       if testing.Short() {
-               n = 10
+       n := 10
+       if *long {
+               n = 1000
        }
 
        const dprec = 3         // max. precision variation
index 3a06fca3c347f636369d861bfa528114f5777478..e16ee5ef20edb563559f716ed7bd5eb9f392b8a8 100644 (file)
@@ -382,9 +382,9 @@ func TestFloat32Distribution(t *testing.T) {
                9,
                11,
        }
-       var winc, einc = uint64(1), 1 // soak test (~1.5s on x86-64)
+       var winc, einc = uint64(5), 15 // quick test (~60ms on x86-64)
        if testing.Short() {
-               winc, einc = 5, 15 // quick test (~60ms on x86-64)
+               winc, einc = uint64(1), 1 // soak test (~1.5s on x86-64)
        }
 
        for _, sign := range "+-" {
@@ -430,9 +430,9 @@ func TestFloat64Distribution(t *testing.T) {
                9,
                11,
        }
-       var winc, einc = uint64(1), 1 // soak test (~75s on x86-64)
-       if testing.Short() {
-               winc, einc = 10, 500 // quick test (~12ms on x86-64)
+       var winc, einc = uint64(10), 500 // quick test (~12ms on x86-64)
+       if *long {
+               winc, einc = uint64(1), 1 // soak test (~75s on x86-64)
        }
 
        for _, sign := range "+-" {
index 3a191a6f53e1cb02f3af80b22e3d6c50ccc0a6f6..56ac8d7aa3a90dfd268057589f27ea22f1a2bbd0 100644 (file)
@@ -144,7 +144,7 @@ func TestFloatString(t *testing.T) {
 }
 
 // Test inputs to Rat.SetString. The prefix "long:" causes the test
-// to be skipped in --test.short mode.  (The threshold is about 500us.)
+// to be skipped except in -long mode.  (The threshold is about 500us.)
 var float64inputs = []string{
        // Constants plundered from strconv/testfp.txt.
 
@@ -350,7 +350,7 @@ func isFinite(f float64) bool {
 func TestFloat32SpecialCases(t *testing.T) {
        for _, input := range float64inputs {
                if strings.HasPrefix(input, "long:") {
-                       if testing.Short() {
+                       if !*long {
                                continue
                        }
                        input = input[len("long:"):]
@@ -406,7 +406,7 @@ func TestFloat32SpecialCases(t *testing.T) {
 func TestFloat64SpecialCases(t *testing.T) {
        for _, input := range float64inputs {
                if strings.HasPrefix(input, "long:") {
-                       if testing.Short() {
+                       if !*long {
                                continue
                        }
                        input = input[len("long:"):]