servetest: add -sub-run flag for running a subset of the backend tests

Use like this (eg in cmd/serve/sftp)

    go test -v -run TestSftp/Normal -sub-run "TestIntegration/FsMkdir/FsPutFiles/FsDirMove"
This commit is contained in:
Nick Craig-Wood 2020-11-10 16:45:47 +00:00
parent f7efce594b
commit e204f89685

View File

@ -5,6 +5,7 @@ package servetest
import ( import (
"context" "context"
"flag"
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
@ -20,6 +21,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
var subRun = flag.String("sub-run", "", "pass this to the -run command of the backend tests")
// StartFn describes the callback which should start the server with // StartFn describes the callback which should start the server with
// the Fs passed in. // the Fs passed in.
// It should return a config for the backend used to connect to the // It should return a config for the backend used to connect to the
@ -74,6 +77,9 @@ func run(t *testing.T, name string, start StartFn, useProxy bool) {
args = append(args, "-verbose") args = append(args, "-verbose")
} }
remoteName := name + "test:" remoteName := name + "test:"
if *subRun != "" {
args = append(args, "-run", *subRun)
}
args = append(args, "-remote", remoteName) args = append(args, "-remote", remoteName)
args = append(args, "-list-retries", fmt.Sprint(*fstest.ListRetries)) args = append(args, "-list-retries", fmt.Sprint(*fstest.ListRetries))
cmd := exec.Command("go", args...) cmd := exec.Command("go", args...)