diff options
Diffstat (limited to 'test/runtimes')
-rw-r--r-- | test/runtimes/go/proctor-go.go | 9 | ||||
-rw-r--r-- | test/runtimes/nodejs/proctor-nodejs.go | 8 | ||||
-rw-r--r-- | test/runtimes/python/proctor-python.go | 14 |
3 files changed, 17 insertions, 14 deletions
diff --git a/test/runtimes/go/proctor-go.go b/test/runtimes/go/proctor-go.go index eae8b5e55..3751c2c81 100644 --- a/test/runtimes/go/proctor-go.go +++ b/test/runtimes/go/proctor-go.go @@ -94,7 +94,8 @@ func (g goRunner) ListTests() ([]string, error) { func (g goRunner) RunTest(test string) error { // Check if test exists on disk by searching for file of the same name. // This will determine whether or not it is a Go test on disk. - if _, err := os.Stat(test); err == nil { + if strings.HasSuffix(test, ".go") { + // Test has suffix ".go" which indicates a disk test, run it as such. relPath, err := filepath.Rel(testDir, test) if err != nil { return fmt.Errorf("failed to get rel path: %v", err) @@ -105,15 +106,13 @@ func (g goRunner) RunTest(test string) error { if err := cmd.Run(); err != nil { return fmt.Errorf("failed to run test: %v", err) } - } else if os.IsNotExist(err) { - // File was not found, try running as Go tool test. + } else { + // No ".go" suffix, run as a tool test. cmd := exec.Command(goBin, "tool", "dist", "test", "-run", test) cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr if err := cmd.Run(); err != nil { return fmt.Errorf("failed to run test: %v", err) } - } else { - return fmt.Errorf("error searching for test: %v", err) } return nil } diff --git a/test/runtimes/nodejs/proctor-nodejs.go b/test/runtimes/nodejs/proctor-nodejs.go index 468025682..0885516e9 100644 --- a/test/runtimes/nodejs/proctor-nodejs.go +++ b/test/runtimes/nodejs/proctor-nodejs.go @@ -28,6 +28,7 @@ import ( var ( dir = os.Getenv("LANG_DIR") + testDir = filepath.Join(dir, "test") testRegEx = regexp.MustCompile(`^test-.+\.js$`) ) @@ -42,16 +43,15 @@ func main() { func (n nodejsRunner) ListTests() ([]string, error) { var testSlice []string - root := filepath.Join(dir, "test") - err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(testDir, func(path string, info os.FileInfo, err error) error { name := filepath.Base(path) if info.IsDir() || !testRegEx.MatchString(name) { return nil } - relPath, err := filepath.Rel(root, path) + relPath, err := filepath.Rel(testDir, path) if err != nil { return err } @@ -60,7 +60,7 @@ func (n nodejsRunner) ListTests() ([]string, error) { }) if err != nil { - return nil, fmt.Errorf("walking %q: %v", root, err) + return nil, fmt.Errorf("walking %q: %v", testDir, err) } return testSlice, nil diff --git a/test/runtimes/python/proctor-python.go b/test/runtimes/python/proctor-python.go index 3f83f3d70..816b1f44a 100644 --- a/test/runtimes/python/proctor-python.go +++ b/test/runtimes/python/proctor-python.go @@ -28,6 +28,7 @@ import ( var ( dir = os.Getenv("LANG_DIR") + testDir = filepath.Join(dir, "Lib", "test") testRegEx = regexp.MustCompile(`^test_.+\.py$`) ) @@ -42,16 +43,15 @@ func main() { func (p pythonRunner) ListTests() ([]string, error) { var testSlice []string - root := filepath.Join(dir, "Lib/test") - err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(testDir, func(path string, info os.FileInfo, err error) error { name := filepath.Base(path) if info.IsDir() || !testRegEx.MatchString(name) { return nil } - relPath, err := filepath.Rel(root, path) + relPath, err := filepath.Rel(testDir, path) if err != nil { return err } @@ -60,15 +60,19 @@ func (p pythonRunner) ListTests() ([]string, error) { }) if err != nil { - return nil, fmt.Errorf("walking %q: %v", root, err) + return nil, fmt.Errorf("walking %q: %v", testDir, err) } return testSlice, nil } func (p pythonRunner) RunTest(test string) error { - args := []string{"-m", "test", test} + // Python tests need to be run in the directory in which they exist. + // Split the filename from it's directory and execute in the correct directory. + relDir, file := filepath.Split(test) + args := []string{"-m", "test", file} cmd := exec.Command(filepath.Join(dir, "python"), args...) + cmd.Dir = filepath.Join(testDir, relDir) cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr if err := cmd.Run(); err != nil { return fmt.Errorf("failed to run: %v", err) |