summaryrefslogtreecommitdiffhomepage
path: root/test/runtimes/nodejs
diff options
context:
space:
mode:
Diffstat (limited to 'test/runtimes/nodejs')
-rw-r--r--test/runtimes/nodejs/BUILD1
-rw-r--r--test/runtimes/nodejs/Dockerfile6
-rw-r--r--test/runtimes/nodejs/proctor-nodejs.go78
3 files changed, 20 insertions, 65 deletions
diff --git a/test/runtimes/nodejs/BUILD b/test/runtimes/nodejs/BUILD
index 0fe5ff83e..0594c250b 100644
--- a/test/runtimes/nodejs/BUILD
+++ b/test/runtimes/nodejs/BUILD
@@ -5,4 +5,5 @@ package(licenses = ["notice"])
go_binary(
name = "proctor-nodejs",
srcs = ["proctor-nodejs.go"],
+ deps = ["//test/runtimes/common"],
)
diff --git a/test/runtimes/nodejs/Dockerfile b/test/runtimes/nodejs/Dockerfile
index b2416cce8..ce2943af8 100644
--- a/test/runtimes/nodejs/Dockerfile
+++ b/test/runtimes/nodejs/Dockerfile
@@ -22,8 +22,10 @@ RUN ./configure
RUN make
RUN make test-build
-COPY proctor-nodejs.go ${LANG_DIR}
+COPY common /root/go/src/gvisor.dev/gvisor/test/runtimes/common/common
+COPY nodejs/proctor-nodejs.go ${LANG_DIR}
+RUN ["/root/go/bin/go", "build", "-o", "/root/go/bin/proctor", "proctor-nodejs.go"]
# Including dumb-init emulates the Linux "init" process, preventing the failure
# of tests involving worker processes.
-ENTRYPOINT ["/usr/bin/dumb-init", "/root/go/bin/go", "run", "proctor-nodejs.go"]
+ENTRYPOINT ["/usr/bin/dumb-init", "/root/go/bin/proctor"]
diff --git a/test/runtimes/nodejs/proctor-nodejs.go b/test/runtimes/nodejs/proctor-nodejs.go
index 8ddfb67fe..0624f6a0d 100644
--- a/test/runtimes/nodejs/proctor-nodejs.go
+++ b/test/runtimes/nodejs/proctor-nodejs.go
@@ -16,93 +16,45 @@
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(`^test-.+\.js$`)
+ testDir = filepath.Join(dir, "test")
+ testRegEx = regexp.MustCompile(`^test-[^-].+\.js$`)
)
-func main() {
- flag.Parse()
+type nodejsRunner 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("Node.js version: ", os.Getenv("LANG_VER"), " is installed.")
- return
- }
- if *test != "" {
- runTest(*test)
- return
+func main() {
+ if err := common.LaunchFunc(nodejsRunner{}); err != nil {
+ log.Fatalf("Failed to start: %v", err)
}
- runAllTests()
}
-func listTests() ([]string, error) {
- var testSlice []string
- root := filepath.Join(dir, "test")
-
- err := filepath.Walk(root, 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)
- if err != nil {
- return err
- }
- testSlice = append(testSlice, relPath)
- return nil
- })
-
+func (n nodejsRunner) ListTests() ([]string, error) {
+ testSlice, err := common.Search(testDir, testRegEx)
if err != nil {
- return nil, fmt.Errorf("walking %q: %v", root, err)
+ return nil, err
}
-
return testSlice, nil
}
-func runTest(test string) {
+func (n nodejsRunner) RunTest(test string) error {
args := []string{filepath.Join(dir, "tools", "test.py"), test}
cmd := exec.Command("/usr/bin/python", 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
}