mirror of
https://github.com/rclone/rclone
synced 2024-11-27 05:23:40 +01:00
fstest/test_all: add oneonly flag to only run one test per backend if required
This commit is contained in:
parent
f97c4c8d9d
commit
1bfd07567e
@ -28,6 +28,7 @@ type Backend struct {
|
||||
Remote string // name of the test remote
|
||||
SubDir bool // set to test with -sub-dir
|
||||
FastList bool // set to test with -fast-list
|
||||
OneOnly bool // set to run only one backend test at once
|
||||
}
|
||||
|
||||
// MakeRuns creates Run objects the Backend and Test
|
||||
@ -52,6 +53,7 @@ func (b *Backend) MakeRuns(t *Test) (runs []*Run) {
|
||||
SubDir: subdir,
|
||||
FastList: fastlist,
|
||||
NoRetries: t.NoRetries,
|
||||
OneOnly: b.OneOnly,
|
||||
}
|
||||
if t.AddBackend {
|
||||
run.Path = path.Join(run.Path, b.Backend)
|
||||
|
@ -77,6 +77,7 @@ backends:
|
||||
remote: "TestQingStor:"
|
||||
subdir: false
|
||||
fastlist: false
|
||||
oneonly: true
|
||||
- backend: "azureblob"
|
||||
remote: "TestAzureBlob:"
|
||||
subdir: true
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
@ -21,6 +22,12 @@ import (
|
||||
|
||||
const testBase = "github.com/ncw/rclone/"
|
||||
|
||||
// Control concurrency per backend if required
|
||||
var (
|
||||
oneOnlyMu sync.Mutex
|
||||
oneOnly = map[string]*sync.Mutex{}
|
||||
)
|
||||
|
||||
// Run holds info about a running test
|
||||
//
|
||||
// A run just runs one command line, but it can be run multiple times
|
||||
@ -33,6 +40,7 @@ type Run struct {
|
||||
SubDir bool // add -sub-dir to tests
|
||||
FastList bool // add -fast-list to tests
|
||||
NoRetries bool // don't retry if set
|
||||
OneOnly bool // only run test for this backend at once
|
||||
// Internals
|
||||
cmdLine []string
|
||||
cmdString string
|
||||
@ -300,6 +308,17 @@ func (r *Run) FailedTests() string {
|
||||
|
||||
// Run runs all the trials for this test
|
||||
func (r *Run) Run(logDir string, result chan<- *Run) {
|
||||
if r.OneOnly {
|
||||
oneOnlyMu.Lock()
|
||||
mu := oneOnly[r.Backend]
|
||||
if mu == nil {
|
||||
mu = new(sync.Mutex)
|
||||
oneOnly[r.Backend] = mu
|
||||
}
|
||||
oneOnlyMu.Unlock()
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
}
|
||||
r.Init()
|
||||
r.logDir = logDir
|
||||
for r.try = 1; r.try <= *maxTries; r.try++ {
|
||||
|
Loading…
Reference in New Issue
Block a user