aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/csource_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-02-13 13:26:26 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-02-13 13:26:26 +0100
commite62476535024c45e4832c2dc01d07a3f0aa930a0 (patch)
tree5403f5d99be31d250acc2b2b2974703101f7a413 /pkg/csource/csource_test.go
parent84f4fc8afc9aedba4b3afa4bb76c3df6c6352c07 (diff)
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.
Diffstat (limited to 'pkg/csource/csource_test.go')
-rw-r--r--pkg/csource/csource_test.go19
1 files changed, 19 insertions, 0 deletions
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)
}