mirror of https://github.com/rclone/rclone.git
fstest/test_all: fix directories that tests are run in
- Don't build a binary for backend tests - Run tests in their relevant directories
This commit is contained in:
parent
fe61cff079
commit
5c32b32011
|
@ -18,6 +18,7 @@ type Test struct {
|
||||||
FastList bool // if it is possible to add -fast-list to tests
|
FastList bool // if it is possible to add -fast-list to tests
|
||||||
AddBackend bool // set if Path needs the current backend appending
|
AddBackend bool // set if Path needs the current backend appending
|
||||||
NoRetries bool // set if no retries should be performed
|
NoRetries bool // set if no retries should be performed
|
||||||
|
NoBinary bool // set to not build a binary in advance
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backend describes a backend test
|
// Backend describes a backend test
|
||||||
|
@ -54,6 +55,7 @@ func (b *Backend) MakeRuns(t *Test) (runs []*Run) {
|
||||||
FastList: fastlist,
|
FastList: fastlist,
|
||||||
NoRetries: t.NoRetries,
|
NoRetries: t.NoRetries,
|
||||||
OneOnly: b.OneOnly,
|
OneOnly: b.OneOnly,
|
||||||
|
NoBinary: t.NoBinary,
|
||||||
}
|
}
|
||||||
if t.AddBackend {
|
if t.AddBackend {
|
||||||
run.Path = path.Join(run.Path, b.Backend)
|
run.Path = path.Join(run.Path, b.Backend)
|
||||||
|
|
|
@ -2,6 +2,7 @@ tests:
|
||||||
- path: backend
|
- path: backend
|
||||||
addbackend: true
|
addbackend: true
|
||||||
noretries: true
|
noretries: true
|
||||||
|
nobinary: true
|
||||||
- path: fs/operations
|
- path: fs/operations
|
||||||
subdir: true
|
subdir: true
|
||||||
fastlist: true
|
fastlist: true
|
||||||
|
|
|
@ -41,6 +41,7 @@ type Run struct {
|
||||||
FastList bool // add -fast-list to tests
|
FastList bool // add -fast-list to tests
|
||||||
NoRetries bool // don't retry if set
|
NoRetries bool // don't retry if set
|
||||||
OneOnly bool // only run test for this backend at once
|
OneOnly bool // only run test for this backend at once
|
||||||
|
NoBinary bool // set to not build a binary
|
||||||
// Internals
|
// Internals
|
||||||
cmdLine []string
|
cmdLine []string
|
||||||
cmdString string
|
cmdString string
|
||||||
|
@ -179,6 +180,7 @@ func (r *Run) trial() {
|
||||||
cmd := exec.Command(cmdLine[0], cmdLine[1:]...)
|
cmd := exec.Command(cmdLine[0], cmdLine[1:]...)
|
||||||
cmd.Stderr = multiOut
|
cmd.Stderr = multiOut
|
||||||
cmd.Stdout = multiOut
|
cmd.Stdout = multiOut
|
||||||
|
cmd.Dir = r.Path
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
r.err = cmd.Run()
|
r.err = cmd.Run()
|
||||||
r.output = b.Bytes()
|
r.output = b.Bytes()
|
||||||
|
@ -226,25 +228,19 @@ func (r *Run) PackagePath() string {
|
||||||
return path.Join(GOPATH(), "src", r.Path)
|
return path.Join(GOPATH(), "src", r.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chdir into the package directory
|
|
||||||
func (r *Run) Chdir() {
|
|
||||||
err := os.Chdir(r.PackagePath())
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to chdir to package %q: %v", r.Path, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MakeTestBinary makes the binary we will run
|
// MakeTestBinary makes the binary we will run
|
||||||
func (r *Run) MakeTestBinary() {
|
func (r *Run) MakeTestBinary() {
|
||||||
binary := r.BinaryPath()
|
binary := r.BinaryPath()
|
||||||
binaryName := r.BinaryName()
|
binaryName := r.BinaryName()
|
||||||
log.Printf("%s: Making test binary %q", r.Path, binaryName)
|
log.Printf("%s: Making test binary %q", r.Path, binaryName)
|
||||||
cmdLine := []string{"go", "test", "-c", "-o", binary, testBase + r.Path}
|
cmdLine := []string{"go", "test", "-c"}
|
||||||
if *dryRun {
|
if *dryRun {
|
||||||
log.Printf("Not executing: %v", cmdLine)
|
log.Printf("Not executing: %v", cmdLine)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := exec.Command(cmdLine[0], cmdLine[1:]...).Run()
|
cmd := exec.Command(cmdLine[0], cmdLine[1:]...)
|
||||||
|
cmd.Dir = r.Path
|
||||||
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to make test binary: %v", err)
|
log.Fatalf("Failed to make test binary: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -286,15 +282,21 @@ func (r *Run) Name() string {
|
||||||
|
|
||||||
// Init the Run
|
// Init the Run
|
||||||
func (r *Run) Init() {
|
func (r *Run) Init() {
|
||||||
binary := r.BinaryPath()
|
prefix := "-test."
|
||||||
r.cmdLine = []string{binary, "-test.v", "-test.timeout", timeout.String(), "-remote", r.Remote}
|
if r.NoBinary {
|
||||||
|
prefix = "-"
|
||||||
|
r.cmdLine = []string{"go", "test"}
|
||||||
|
} else {
|
||||||
|
r.cmdLine = []string{"./" + r.BinaryName()}
|
||||||
|
}
|
||||||
|
r.cmdLine = append(r.cmdLine, prefix+"v", prefix+"timeout", timeout.String(), "-remote", r.Remote)
|
||||||
r.try = 1
|
r.try = 1
|
||||||
if *verbose {
|
if *verbose {
|
||||||
r.cmdLine = append(r.cmdLine, "-verbose")
|
r.cmdLine = append(r.cmdLine, "-verbose")
|
||||||
fs.Config.LogLevel = fs.LogLevelDebug
|
fs.Config.LogLevel = fs.LogLevelDebug
|
||||||
}
|
}
|
||||||
if *runOnly != "" {
|
if *runOnly != "" {
|
||||||
r.cmdLine = append(r.cmdLine, "-test.run", *runOnly)
|
r.cmdLine = append(r.cmdLine, prefix+"run", *runOnly)
|
||||||
}
|
}
|
||||||
if r.SubDir {
|
if r.SubDir {
|
||||||
r.cmdLine = append(r.cmdLine, "-subdir")
|
r.cmdLine = append(r.cmdLine, "-subdir")
|
||||||
|
|
|
@ -109,10 +109,12 @@ func main() {
|
||||||
for _, run := range runs {
|
for _, run := range runs {
|
||||||
if _, found := done[run.Path]; !found {
|
if _, found := done[run.Path]; !found {
|
||||||
done[run.Path] = struct{}{}
|
done[run.Path] = struct{}{}
|
||||||
|
if !run.NoBinary {
|
||||||
run.MakeTestBinary()
|
run.MakeTestBinary()
|
||||||
defer run.RemoveTestBinary()
|
defer run.RemoveTestBinary()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// workaround for cache backend as we run simultaneous tests
|
// workaround for cache backend as we run simultaneous tests
|
||||||
_ = os.Setenv("RCLONE_CACHE_DB_WAIT_TIME", "30m")
|
_ = os.Setenv("RCLONE_CACHE_DB_WAIT_TIME", "30m")
|
||||||
|
|
Loading…
Reference in New Issue