diff options
Diffstat (limited to 'runsc/test/runtimes/proctor-php.go')
-rw-r--r-- | runsc/test/runtimes/proctor-php.go | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/runsc/test/runtimes/proctor-php.go b/runsc/test/runtimes/proctor-php.go index 3d305c709..9dfb33b04 100644 --- a/runsc/test/runtimes/proctor-php.go +++ b/runsc/test/runtimes/proctor-php.go @@ -42,18 +42,28 @@ func main() { os.Exit(1) } if *list { - listTests() + tests, err := listTests() + if err != nil { + log.Fatalf("Failed to list tests: %v", err) + } + for _, test := range tests { + fmt.Println(test) + } return } if *version { fmt.Println("PHP version: ", os.Getenv("LANG_VER"), " is installed.") return } - runTest(*test) + if *test != "" { + runTest(*test) + return + } + runAllTests() } -func listTests() { - var files []string +func listTests() ([]string, error) { + var testSlice []string err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { name := filepath.Base(path) @@ -66,27 +76,32 @@ func listTests() { if err != nil { return err } - files = append(files, relPath) + testSlice = append(testSlice, relPath) return nil }) if err != nil { - log.Fatalf("Failed to walk %q: %v", dir, err) + return nil, fmt.Errorf("walking %q: %v", dir, err) } - for _, file := range files { - fmt.Println(file) - } + return testSlice, nil } func runTest(test string) { - args := []string{"test", "TESTS="} - if test != "" { - args[1] = args[1] + test - } + args := []string{"test", "TESTS=" + test} cmd := exec.Command("make", args...) cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr if err := cmd.Run(); err != nil { log.Fatalf("Failed to run: %v", err) } } + +func runAllTests() { + tests, err := listTests() + if err != nil { + log.Fatalf("Failed to list tests: %v", err) + } + for _, test := range tests { + runTest(test) + } +} |