From 6a1ac3407743adf7c0493ab9da97a1dff4e4b2ac Mon Sep 17 00:00:00 2001 From: Brett Landau Date: Thu, 1 Aug 2019 18:49:40 -0700 Subject: Refactor ListTests() to common.Search(). This change removes the filepath.Walk() function from proctor- go, php, and nodejs. The filepath.Walk() is now defined in common.go in Search(). Each proctor binary passes root directory and testFilter arguments to Search(). proctor-python.go no longer uses filepath.Walk() to search for tests. There is a built-in list test function within python's language test suite so that is being used instead. PiperOrigin-RevId: 261242897 --- test/runtimes/php/proctor-php.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'test/runtimes/php') diff --git a/test/runtimes/php/proctor-php.go b/test/runtimes/php/proctor-php.go index 3ee4cf056..e6c5fabdf 100644 --- a/test/runtimes/php/proctor-php.go +++ b/test/runtimes/php/proctor-php.go @@ -20,7 +20,6 @@ import ( "log" "os" "os/exec" - "path/filepath" "regexp" "gvisor.dev/gvisor/test/runtimes/common" @@ -41,27 +40,10 @@ func main() { } func (p phpRunner) ListTests() ([]string, error) { - var testSlice []string - - err := filepath.Walk(dir, 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(dir, path) - if err != nil { - return err - } - testSlice = append(testSlice, relPath) - return nil - }) - + testSlice, err := common.Search(dir, testRegEx) if err != nil { - return nil, fmt.Errorf("walking %q: %v", dir, err) + return nil, err } - return testSlice, nil } -- cgit v1.2.3