"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Retry only the failing tests in the integration tests
Nick Craig-Wood5c2d8ffe3391
diff --git a/fs/test_all.go b/fs/test_all.goindex 23b750157..51ebd8ce3 100644--- a/fs/test_all.go+++ b/fs/test_all.go@@ -10,6 +10,7 @@ import ("log""os""os/exec"+ "regexp""runtime""strings""time"@@ -34,8 +35,8 @@ var (}binary = "fs.test"// Flags- maxTries = flag.Int("maxtries", 3, "Number of times to try each test")- runTests = flag.String("run", "", "Comma separated list of remotes to test, eg 'TestSwift:,TestS3'")+ maxTries = flag.Int("maxtries", 5, "Number of times to try each test")+ runTests = flag.String("remotes", "", "Comma separated list of remotes to test, eg 'TestSwift:,TestS3'")verbose = flag.Bool("verbose", false, "Run the tests with -v")clean = flag.Bool("clean", false, "Instead of testing, clean all left over test directories")runOnly = flag.String("run-only", "", "Run only those tests matching the regexp supplied")@@ -43,13 +44,15 @@ var (// test holds info about a running testtype test struct {- remote string- subdir bool- cmdLine []string- cmdString string- try int- err error- output []byte+ remote string+ subdir bool+ cmdLine []string+ cmdString string+ try int+ err error+ output []byte+ failedTests []string+ runFlag string}// newTest creates a new test@@ -73,17 +76,43 @@ func newTest(remote string, subdir bool) *test {return t}+var failRe = regexp.MustCompile(`(?m)^--- FAIL: (Test\w*) \(`)++// findFailures looks for all the tests which failed+func (t *test) findFailures() {+ t.failedTests = nil+ for _, matches := range failRe.FindAllSubmatch(t.output, -1) {+ t.failedTests = append(t.failedTests, string(matches[1]))+ }+ if len(t.failedTests) != 0 {+ t.runFlag = "^(" + strings.Join(t.failedTests, "|") + ")$"+ } else {+ t.runFlag = ""+ }+ if t.passed() && len(t.failedTests) != 0 {+ log.Printf("%q - Expecting no errors but got: %v", t.cmdString, t.failedTests)+ } else if !t.passed() && len(t.failedTests) == 0 {+ log.Printf("%q - Expecting errors but got none: %v", t.cmdString, t.failedTests)+ }+}+// trial runs a single testfunc (t *test) trial() {- log.Printf("%q - Starting (try %d/%d)", t.cmdString, t.try, *maxTries)- cmd := exec.Command(t.cmdLine[0], t.cmdLine[1:]...)+ cmdLine := t.cmdLine[:]+ if t.runFlag != "" {+ cmdLine = append(cmdLine, "-test.run", t.runFlag)+ }+ cmdString := strings.Join(cmdLine, " ")+ log.Printf("%q - Starting (try %d/%d)", cmdString, t.try, *maxTries)+ cmd := exec.Command(cmdLine[0], cmdLine[1:]...)start := time.Now()t.output, t.err = cmd.CombinedOutput()duration := time.Since(start)+ t.findFailures()if t.passed() {- log.Printf("%q - Finished OK in %v (try %d/%d)", t.cmdString, duration, t.try, *maxTries)+ log.Printf("%q - Finished OK in %v (try %d/%d)", cmdString, duration, t.try, *maxTries)} else {- log.Printf("%q - Finished ERROR in %v (try %d/%d): %v", t.cmdString, duration, t.try, *maxTries, t.err)+ log.Printf("%q - Finished ERROR in %v (try %d/%d): %v: Failed %v", cmdString, duration, t.try, *maxTries, t.err, t.failedTests)}}@@ -93,7 +122,8 @@ func (t *test) cleanFs() error {if err != nil {return err}- for dir := range f.ListDir() {+ dirs, err := fs.NewLister().SetLevel(1).Start(f, "").GetDirs()+ for _, dir := range dirs {if fstest.MatchTestRemote.MatchString(dir.Name) {log.Printf("Purging %s%s", t.remote, dir.Name)dir, err := fs.NewFs(t.remote + dir.Name)