From 9846445c8e6e35393c6bf8e27a3ac83f70368e63 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 4 May 2018 20:06:00 +0200 Subject: prog: parallelize tests Parallelize more tests and reduce number of iterations in random tests under race detector. --- prog/export_test.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'prog/export_test.go') 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 -- cgit mrf-deployment