From e62476535024c45e4832c2dc01d07a3f0aa930a0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 13 Feb 2020 13:26:26 +0100 Subject: pkg/csource: don't print too much error output We print whole reproducer programs on failure, if lots of programs fail, this results in thousands of lines of output, which is esp bad on travis. Limit amount of output. --- pkg/csource/csource_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'pkg/csource/csource_test.go') diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 162fcf788..59ca230b6 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -13,6 +13,7 @@ import ( "regexp" "runtime" "strings" + "sync/atomic" "testing" "time" @@ -108,14 +109,32 @@ func testTarget(t *testing.T, target *prog.Target, full bool) { } } +var failedTests uint32 + func testOne(t *testing.T, p *prog.Prog, opts Options) { + // Each failure produces lots of output (including full C source). + // Frequently lots of tests fail at the same, which produces/tmp/log + // tens of thounds of lines of output. Limit amount of output. + maxFailures := uint32(10) + if os.Getenv("TRAVIS") != "" { + maxFailures = 1 + } + if atomic.LoadUint32(&failedTests) > maxFailures { + return + } src, err := Write(p, opts) if err != nil { + if atomic.AddUint32(&failedTests, 1) > maxFailures { + t.Fatal() + } t.Logf("opts: %+v\nprogram:\n%s\n", opts, p.Serialize()) t.Fatalf("%v", err) } bin, err := Build(p.Target, src) if err != nil { + if atomic.AddUint32(&failedTests, 1) > maxFailures { + t.Fatal() + } t.Logf("opts: %+v\nprogram:\n%s\n", opts, p.Serialize()) t.Fatalf("%v", err) } -- cgit mrf-deployment