[testsharder] Skip visited directories
This fixes a bug in which the same metadata directories were being
visited multiple times (in the case where multiple linux/mac tests are
defined in the same BUILD.gn file.)
Change-Id: I8ceed766c7e4d6c495f09f4190b148647f07194d
diff --git a/testsharder/test_spec.go b/testsharder/test_spec.go
index 5cb537f..d420f9f 100644
--- a/testsharder/test_spec.go
+++ b/testsharder/test_spec.go
@@ -162,10 +162,16 @@
// corresponding package its test was defined in: specifically, it will be put in
// <target_out_dir of the test package>/<test package name>.
specs := []TestSpec{}
+ processedDirs := make(map[string]bool)
decodeTestSpecs := func(targets []build.Target, testSpecDir func(string, build.Target) string) error {
for _, target := range targets {
specDir := testSpecDir(fuchsiaBuildDir, target)
+ if _, ok := processedDirs[specDir]; ok {
+ continue
+ }
+ processedDirs[specDir] = true
+
// If the associated test spec directory does not exist, the package specified no
// tests.
if _, err := os.Stat(specDir); os.IsNotExist(err) {