aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-05-16 16:16:36 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-18 11:34:42 +0200
commitb6fa239fd5e9e120ac2b8e9f3d7f608125a7f986 (patch)
treecf2bd7c58004da4db974893f1c2c6cd418664127 /pkg
parent04875dc64477a3d369d8a125d0752bf4fb06bfef (diff)
pkg/csource: speed up tests
Tests run for too long. 1. Check only 1 arch per OS in short mode. 2. Dedup options. Turns out we generated 2x duplicates in allOptionsSingle.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/csource/csource_test.go5
-rw-r--r--pkg/csource/options_test.go18
2 files changed, 20 insertions, 3 deletions
diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go
index 61b6bcf31..a5b12babf 100644
--- a/pkg/csource/csource_test.go
+++ b/pkg/csource/csource_test.go
@@ -32,10 +32,13 @@ func TestGenerate(t *testing.T) {
continue
}
t.Run(target.OS+"/"+target.Arch, func(t *testing.T) {
+ full := !checked[target.OS]
+ if !full && testing.Short() {
+ return
+ }
if err := sysTarget.BrokenCompiler; err != "" {
t.Skipf("target compiler is broken: %v", err)
}
- full := !checked[target.OS]
checked[target.OS] = true
t.Parallel()
testTarget(t, target, full)
diff --git a/pkg/csource/options_test.go b/pkg/csource/options_test.go
index d4e1832e7..e1457ea73 100644
--- a/pkg/csource/options_test.go
+++ b/pkg/csource/options_test.go
@@ -148,7 +148,7 @@ func allOptionsSingle(OS string) []Options {
}
opts = append(opts, enumerateField(OS, opt, i)...)
}
- return opts
+ return dedup(opts)
}
func allOptionsPermutations(OS string) []Options {
@@ -161,7 +161,21 @@ func allOptionsPermutations(OS string) []Options {
}
opts = newOpts
}
- return opts
+ return dedup(opts)
+}
+
+func dedup(opts []Options) []Options {
+ pos := 0
+ dedup := make(map[Options]bool)
+ for _, opt := range opts {
+ if dedup[opt] {
+ continue
+ }
+ dedup[opt] = true
+ opts[pos] = opt
+ pos++
+ }
+ return opts[:pos]
}
func enumerateField(OS string, opt Options, field int) []Options {