aboutsummaryrefslogtreecommitdiffstats
path: root/prog/export_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-05-04 20:06:00 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-05-04 20:07:32 +0200
commit9846445c8e6e35393c6bf8e27a3ac83f70368e63 (patch)
treec94cf0b97e8179c55398186db756122d282f1514 /prog/export_test.go
parent2c7e14a847318974490ab59460f0834ea2ee0d24 (diff)
prog: parallelize tests
Parallelize more tests and reduce number of iterations in random tests under race detector.
Diffstat (limited to 'prog/export_test.go')
-rw-r--r--prog/export_test.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/prog/export_test.go b/prog/export_test.go
index 015d4f319..b6247c850 100644
--- a/prog/export_test.go
+++ b/prog/export_test.go
@@ -36,13 +36,20 @@ func randSource(t *testing.T) rand.Source {
return rand.NewSource(seed)
}
-func initRandomTargetTest(t *testing.T, os, arch string) (*Target, rand.Source, int) {
- target := initTargetTest(t, os, arch)
+func iterCount() int {
iters := 10000
if testing.Short() {
iters = 100
}
- return target, randSource(t), iters
+ if raceEnabled {
+ iters /= 10
+ }
+ return iters
+}
+
+func initRandomTargetTest(t *testing.T, os, arch string) (*Target, rand.Source, int) {
+ target := initTargetTest(t, os, arch)
+ return target, randSource(t), iterCount()
}
func initTest(t *testing.T) (*Target, rand.Source, int) {
@@ -50,6 +57,7 @@ func initTest(t *testing.T) (*Target, rand.Source, int) {
}
func testEachTarget(t *testing.T, fn func(t *testing.T, target *Target)) {
+ t.Parallel()
for _, target := range AllTargets() {
target := target
t.Run(fmt.Sprintf("%v/%v", target.OS, target.Arch), func(t *testing.T) {
@@ -60,12 +68,13 @@ func testEachTarget(t *testing.T, fn func(t *testing.T, target *Target)) {
}
func testEachTargetRandom(t *testing.T, fn func(t *testing.T, target *Target, rs rand.Source, iters int)) {
- iters := 10000
- if testing.Short() {
- iters = 100
- }
+ t.Parallel()
targets := AllTargets()
+ iters := iterCount()
iters /= len(targets)
+ if iters < 3 {
+ iters = 3
+ }
rs0 := randSource(t)
for _, target := range targets {
target := target