From b6fa239fd5e9e120ac2b8e9f3d7f608125a7f986 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 16 May 2020 16:16:36 +0200 Subject: 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. --- pkg/csource/options_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'pkg/csource/options_test.go') 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 { -- cgit mrf-deployment