summaryrefslogtreecommitdiffhomepage
path: root/test/runtimes/php
diff options
context:
space:
mode:
Diffstat (limited to 'test/runtimes/php')
-rw-r--r--test/runtimes/php/BUILD1
-rw-r--r--test/runtimes/php/Dockerfile6
-rw-r--r--test/runtimes/php/proctor-php.go75
3 files changed, 18 insertions, 64 deletions
diff --git a/test/runtimes/php/BUILD b/test/runtimes/php/BUILD
index 22aef7ba4..31799b77a 100644
--- a/test/runtimes/php/BUILD
+++ b/test/runtimes/php/BUILD
@@ -5,4 +5,5 @@ package(licenses = ["notice"])
go_binary(
name = "proctor-php",
srcs = ["proctor-php.go"],
+ deps = ["//test/runtimes/common"],
)
diff --git a/test/runtimes/php/Dockerfile b/test/runtimes/php/Dockerfile
index 1f8959b50..d79babe58 100644
--- a/test/runtimes/php/Dockerfile
+++ b/test/runtimes/php/Dockerfile
@@ -24,6 +24,8 @@ WORKDIR ${LANG_DIR}
RUN ./configure
RUN make
-COPY proctor-php.go ${LANG_DIR}
+COPY common /root/go/src/gvisor.dev/gvisor/test/runtimes/common/common
+COPY php/proctor-php.go ${LANG_DIR}
+RUN ["/root/go/bin/go", "build", "-o", "/root/go/bin/proctor", "proctor-php.go"]
-ENTRYPOINT ["/root/go/bin/go", "run", "proctor-php.go"]
+ENTRYPOINT ["/root/go/bin/proctor"]
diff --git a/test/runtimes/php/proctor-php.go b/test/runtimes/php/proctor-php.go
index 9dfb33b04..e6c5fabdf 100644
--- a/test/runtimes/php/proctor-php.go
+++ b/test/runtimes/php/proctor-php.go
@@ -16,92 +16,43 @@
package main
import (
- "flag"
"fmt"
"log"
"os"
"os/exec"
- "path/filepath"
"regexp"
+
+ "gvisor.dev/gvisor/test/runtimes/common"
)
var (
- list = flag.Bool("list", false, "list all available tests")
- test = flag.String("test", "", "run a single test from the list of available tests")
- version = flag.Bool("v", false, "print out the version of node that is installed")
-
dir = os.Getenv("LANG_DIR")
testRegEx = regexp.MustCompile(`^.+\.phpt$`)
)
-func main() {
- flag.Parse()
+type phpRunner struct {
+}
- if *list && *test != "" {
- flag.PrintDefaults()
- os.Exit(1)
- }
- if *list {
- 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
- }
- if *test != "" {
- runTest(*test)
- return
+func main() {
+ if err := common.LaunchFunc(phpRunner{}); err != nil {
+ log.Fatalf("Failed to start: %v", err)
}
- runAllTests()
}
-func 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
- })
-
+func (p phpRunner) ListTests() ([]string, error) {
+ testSlice, err := common.Search(dir, testRegEx)
if err != nil {
- return nil, fmt.Errorf("walking %q: %v", dir, err)
+ return nil, err
}
-
return testSlice, nil
}
-func runTest(test string) {
+func (p phpRunner) RunTest(test string) error {
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)
+ return fmt.Errorf("failed to run: %v", err)
}
+ return nil
}