From 06a2b89fc3e93a6c381a5d9df229766f706b58d0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 2 Jan 2019 11:55:53 +0100 Subject: prog, pkg/{csource,ifuzz,ipc,repro}: make tests deterministic on travis Don't use random seed on travis as it produces flaky coverage reports, and probably generally better for CI setting. --- prog/export_test.go | 4 ++++ prog/prog_test.go | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'prog') diff --git a/prog/export_test.go b/prog/export_test.go index b6247c850..a49d094ef 100644 --- a/prog/export_test.go +++ b/prog/export_test.go @@ -6,6 +6,7 @@ package prog import ( "fmt" "math/rand" + "os" "testing" "time" ) @@ -32,6 +33,9 @@ func initTargetTest(t *testing.T, os, arch string) *Target { func randSource(t *testing.T) rand.Source { seed := int64(time.Now().UnixNano()) + if os.Getenv("TRAVIS") != "" { + seed = 0 // required for deterministic coverage reports + } t.Logf("seed=%v", seed) return rand.NewSource(seed) } diff --git a/prog/prog_test.go b/prog/prog_test.go index 45ab56cfe..91d7351cc 100644 --- a/prog/prog_test.go +++ b/prog/prog_test.go @@ -9,7 +9,6 @@ import ( "math/rand" "strings" "testing" - "time" ) func TestGeneration(t *testing.T) { @@ -144,9 +143,7 @@ func TestCrossTarget(t *testing.T) { } func testCrossTarget(t *testing.T, target *Target, crossTargets []*Target) { - seed := int64(time.Now().UnixNano()) - t.Logf("seed=%v", seed) - rs := rand.NewSource(seed) + rs := randSource(t) iters := 100 if testing.Short() { iters /= 10 -- cgit mrf-deployment