Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

test_all: make ignored tests also ignore their subtests

Nick Craig-Woodf45e78e29499
diff --git a/fstest/runs/run.go b/fstest/runs/run.go
index c898d3919..4adf28044 100644
--- a/fstest/runs/run.go
+++ b/fstest/runs/run.go
@@ -180,17 +180,24 @@ func (r *Run) findFailures() {
ignored := 0
for _, matches := range failRe.FindAllSubmatch(r.output, -1) {
failedTest := string(matches[1])
- // Skip any ignored failures
- if _, found := r.Ignore[failedTest]; found {
- ignored++
- } else {
- r.FailedTests = append(r.FailedTests, failedTest)
- }
// Find all the parents of this test
parts := strings.Split(failedTest, "/")
for i := len(parts) - 1; i >= 1; i-- {
excludeParents[strings.Join(parts[:i], "/")] = struct{}{}
}
+ // Skip any ignored failures, including subtests of ignored tests
+ isIgnored := false
+ for i := len(parts); i >= 1; i-- {
+ if _, found := r.Ignore[strings.Join(parts[:i], "/")]; found {
+ isIgnored = true
+ break
+ }
+ }
+ if isIgnored {
+ ignored++
+ } else {
+ r.FailedTests = append(r.FailedTests, failedTest)
+ }
}
// Exclude the parents
newTests := r.FailedTests[:0]
diff --git a/fstest/runs/run_test.go b/fstest/runs/run_test.go
index 4353b1417..5d3437e91 100644
--- a/fstest/runs/run_test.go
+++ b/fstest/runs/run_test.go
@@ -1,6 +1,7 @@
package runs
import (
+ "errors"
"fmt"
"os/exec"
"regexp"
@@ -177,3 +178,45 @@ func TestTests(t *testing.T) {
})
})
}
+
+func TestFindFailuresIgnore(t *testing.T) {
+ output := []byte(`--- FAIL: TestOne (0.00s)
+ --- FAIL: TestOne/Sub1 (0.00s)
+ --- FAIL: TestOne/Sub2 (0.00s)
+--- FAIL: TestTwo (0.00s)
+ --- FAIL: TestTwo/Sub1 (0.00s)
+--- FAIL: TestThree (0.00s)
+`)
+ for _, test := range []struct {
+ ignore []string
+ want []string
+ }{
+ {
+ ignore: nil,
+ want: []string{"TestOne/Sub1", "TestOne/Sub2", "TestTwo/Sub1", "TestThree"},
+ },
+ {
+ ignore: []string{"TestOne"},
+ want: []string{"TestTwo/Sub1", "TestThree"},
+ },
+ {
+ ignore: []string{"TestOne/Sub1"},
+ want: []string{"TestOne/Sub2", "TestTwo/Sub1", "TestThree"},
+ },
+ {
+ ignore: []string{"TestOne", "TestTwo", "TestThree"},
+ want: nil,
+ },
+ } {
+ r := &Run{
+ Ignore: map[string]struct{}{},
+ err: errors.New("failed"),
+ output: output,
+ }
+ for _, name := range test.ignore {
+ r.Ignore[name] = struct{}{}
+ }
+ r.findFailures()
+ assert.Equal(t, test.want, r.FailedTests, fmt.Sprintf("ignore=%v", test.ignore))
+ }
+}