mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 08:44:02 +00:00
run_tests: Pass additional parameters to go test
This commit is contained in:
parent
3a65f27c3f
commit
0ad08b2f70
26
run_tests.go
26
run_tests.go
@ -90,7 +90,7 @@ func mergeCoverprofile(file *os.File, out io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPackage(pkg string, out io.Writer) error {
|
func testPackage(pkg string, params []string, out io.Writer) error {
|
||||||
file, err := ioutil.TempFile("", "test-coverage-")
|
file, err := ioutil.TempFile("", "test-coverage-")
|
||||||
defer os.Remove(file.Name())
|
defer os.Remove(file.Name())
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
@ -98,9 +98,10 @@ func testPackage(pkg string, out io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("go", "test",
|
args := []string{"test", "-cover", "-covermode", "set", "-coverprofile",
|
||||||
"-cover", "-covermode", "set", "-coverprofile", file.Name(),
|
file.Name(), pkg}
|
||||||
pkg, "-test.integration")
|
args = append(args, params...)
|
||||||
|
cmd := exec.Command("go", args...)
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
|
|
||||||
@ -114,12 +115,23 @@ func testPackage(pkg string, out io.Writer) error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
fmt.Fprintln(os.Stderr, "USAGE: run_tests COVERPROFILE [PATHS]")
|
fmt.Fprintln(os.Stderr, "USAGE: run_tests COVERPROFILE [TESTFLAGS] [-- [PATHS]]")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
target := os.Args[1]
|
target := os.Args[1]
|
||||||
dirs := os.Args[2:]
|
args := os.Args[2:]
|
||||||
|
|
||||||
|
paramsForTest := []string{}
|
||||||
|
dirs := []string{}
|
||||||
|
for i, arg := range args {
|
||||||
|
if arg == "--" {
|
||||||
|
dirs = args[i+1:]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
paramsForTest = append(paramsForTest, arg)
|
||||||
|
}
|
||||||
|
|
||||||
if len(dirs) == 0 {
|
if len(dirs) == 0 {
|
||||||
dirs = append(dirs, ".")
|
dirs = append(dirs, ".")
|
||||||
@ -152,7 +164,7 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return testPackage(forceRelativeDirname(p), file)
|
return testPackage(forceRelativeDirname(p), paramsForTest, file)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user