summaryrefslogtreecommitdiffhomepage
path: root/test/runtimes/java
diff options
context:
space:
mode:
authorBrett Landau <brettlandau@google.com>2019-07-31 11:34:34 -0700
committergVisor bot <gvisor-bot@google.com>2019-07-31 11:35:47 -0700
commitedcc60b931232d5bea4254af31965da126f07a68 (patch)
treeeda49ea8c8435a74fb0de2e1d3ad0f69f7a230a1 /test/runtimes/java
parent12c4eb294a43f4a84a789871730869d164ef52c9 (diff)
Refactor proctor binaries to implement testRunner interface.
Shared code among proctor-*.go files has been refactored into common/common.go. The common package is imported in each proctor binary and a struct is created to implement the testRunner interface defined in common.go. This allows for the proctor binaries to be updated without having to copy/paste the same code across all files. There are no usage or functionality changes. PiperOrigin-RevId: 260967080
Diffstat (limited to 'test/runtimes/java')
-rw-r--r--test/runtimes/java/BUILD1
-rw-r--r--test/runtimes/java/proctor-java.go53
2 files changed, 12 insertions, 42 deletions
diff --git a/test/runtimes/java/BUILD b/test/runtimes/java/BUILD
index 7e2808ece..8c39d39ec 100644
--- a/test/runtimes/java/BUILD
+++ b/test/runtimes/java/BUILD
@@ -5,4 +5,5 @@ package(licenses = ["notice"])
go_binary(
name = "proctor-java",
srcs = ["proctor-java.go"],
+ deps = ["//test/runtimes/common"],
)
diff --git a/test/runtimes/java/proctor-java.go b/test/runtimes/java/proctor-java.go
index 0177f421d..c1e611b4b 100644
--- a/test/runtimes/java/proctor-java.go
+++ b/test/runtimes/java/proctor-java.go
@@ -16,7 +16,6 @@
package main
import (
- "flag"
"fmt"
"log"
"os"
@@ -24,47 +23,26 @@ import (
"path/filepath"
"regexp"
"strings"
+
+ "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")
jtreg = filepath.Join(dir, "jtreg/bin/jtreg")
exclDirs = regexp.MustCompile(`(^(sun\/security)|(java\/util\/stream)|(java\/time)| )`)
)
-func main() {
- flag.Parse()
+type javaRunner 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("Java version: ", os.Getenv("LANG_VER"), " is installed.")
- return
- }
- if *test != "" {
- runTest(*test)
- return
+func main() {
+ if err := common.LaunchFunc(javaRunner{}); err != nil {
+ log.Fatalf("Failed to start: %v", err)
}
- runAllTests()
}
-func listTests() ([]string, error) {
+func (j javaRunner) ListTests() ([]string, error) {
args := []string{
"-dir:test/jdk",
"-ignore:quiet",
@@ -90,21 +68,12 @@ func listTests() ([]string, error) {
return testSlice, nil
}
-func runTest(test string) {
+func (j javaRunner) RunTest(test string) error {
args := []string{"-dir:test/jdk/", test}
cmd := exec.Command(jtreg, 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
}