summaryrefslogtreecommitdiffhomepage
path: root/runsc/test/runtimes/proctor-java.go
diff options
context:
space:
mode:
authorBrett Landau <brettlandau@google.com>2019-07-23 13:31:30 -0700
committergVisor bot <gvisor-bot@google.com>2019-07-23 13:32:43 -0700
commit57745994384ee1ff94fc7bed4f814ba75e39d48e (patch)
treeb1a4cc396b095259b66e8689e9046fd3a5e5de5e /runsc/test/runtimes/proctor-java.go
parent12c256568ba784c07cf73822359faac2971e8306 (diff)
Make runAllTests() consistent with listTests().
This change has the listTests() function return a string slice of all the tests. Originally, I planned not to modify the listTests() function and instead capture the output of it and then iterate through the captured output. I decided against this approach as most of the test binaries already produce a slice as they collect tests through filepath.Walk(). Now I use this slice and return it so that I can iterate through in runAllTests() and also when printing out the tests. PiperOrigin-RevId: 259599782
Diffstat (limited to 'runsc/test/runtimes/proctor-java.go')
-rw-r--r--runsc/test/runtimes/proctor-java.go43
1 files changed, 30 insertions, 13 deletions
diff --git a/runsc/test/runtimes/proctor-java.go b/runsc/test/runtimes/proctor-java.go
index 50f3789dc..0177f421d 100644
--- a/runsc/test/runtimes/proctor-java.go
+++ b/runsc/test/runtimes/proctor-java.go
@@ -44,17 +44,27 @@ func main() {
os.Exit(1)
}
if *list {
- listTests()
+ 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
}
- runTest(*test)
+ if *test != "" {
+ runTest(*test)
+ return
+ }
+ runAllTests()
}
-func listTests() {
+func listTests() ([]string, error) {
args := []string{
"-dir:test/jdk",
"-ignore:quiet",
@@ -69,25 +79,32 @@ func listTests() {
cmd.Stderr = os.Stderr
out, err := cmd.Output()
if err != nil {
- log.Fatalf("Failed to list: %v", err)
+ return nil, fmt.Errorf("jtreg -listtests : %v", err)
}
- allTests := string(out)
- for _, test := range strings.Split(allTests, "\n") {
+ var testSlice []string
+ for _, test := range strings.Split(string(out), "\n") {
if !exclDirs.MatchString(test) {
- fmt.Println(test)
+ testSlice = append(testSlice, test)
}
}
+ return testSlice, nil
}
func runTest(test string) {
- // TODO(brettlandau): Change to use listTests() for running all tests.
- cmd := exec.Command("make", "run-test-tier1")
- if test != "" {
- args := []string{"-dir:test/jdk/", test}
- cmd = exec.Command(jtreg, args...)
- }
+ 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)
+ }
+}