summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--test/runtimes/BUILD58
-rw-r--r--test/runtimes/defs.bzl79
-rw-r--r--test/runtimes/exclude_go1.12.csv (renamed from test/runtimes/exclude/go1.12.csv)0
-rw-r--r--test/runtimes/exclude_java11.csv (renamed from test/runtimes/exclude/java11.csv)0
-rw-r--r--test/runtimes/exclude_nodejs12.4.0.csv (renamed from test/runtimes/exclude/nodejs12.4.0.csv)0
-rw-r--r--test/runtimes/exclude_php7.3.6.csv (renamed from test/runtimes/exclude/php7.3.6.csv)0
-rw-r--r--test/runtimes/exclude_python3.7.3.csv (renamed from test/runtimes/exclude/python3.7.3.csv)0
-rw-r--r--test/runtimes/runner/BUILD22
-rw-r--r--test/runtimes/runner/exclude_test.go (renamed from test/runtimes/exclude_test.go)2
-rw-r--r--test/runtimes/runner/main.go (renamed from test/runtimes/runner.go)8
10 files changed, 90 insertions, 79 deletions
diff --git a/test/runtimes/BUILD b/test/runtimes/BUILD
index aeefa8f56..f98d02e00 100644
--- a/test/runtimes/BUILD
+++ b/test/runtimes/BUILD
@@ -1,82 +1,38 @@
-load("//test/runtimes:defs.bzl", "exclude_test", "runtime_test")
+load("//test/runtimes:defs.bzl", "runtime_test")
package(licenses = ["notice"])
-go_binary(
- name = "runner",
- testonly = 1,
- srcs = ["runner.go"],
- visibility = ["//test/runtimes:__pkg__"],
- deps = [
- "//pkg/log",
- "//pkg/test/dockerutil",
- "//pkg/test/testutil",
- ],
-)
-
runtime_test(
name = "go1.12",
- exclude_file = "exclude/go1.12.csv",
+ exclude_file = "exclude_go1.12.csv",
lang = "go",
shard_count = 5,
)
runtime_test(
name = "java11",
- exclude_file = "exclude/java11.csv",
+ exclude_file = "exclude_java11.csv",
lang = "java",
- shard_count = 5,
+ shard_count = 10,
)
runtime_test(
name = "nodejs12.4.0",
- exclude_file = "exclude/nodejs12.4.0.csv",
+ exclude_file = "exclude_nodejs12.4.0.csv",
lang = "nodejs",
shard_count = 5,
)
runtime_test(
name = "php7.3.6",
- exclude_file = "exclude/php7.3.6.csv",
+ exclude_file = "exclude_php7.3.6.csv",
lang = "php",
shard_count = 5,
)
runtime_test(
name = "python3.7.3",
- exclude_file = "exclude/python3.7.3.csv",
+ exclude_file = "exclude_python3.7.3.csv",
lang = "python",
shard_count = 5,
)
-
-go_test(
- name = "exclude_test",
- size = "small",
- srcs = ["exclude_test.go"],
- library = ":runner",
-)
-
-exclude_test(
- name = "go",
- exclude_file = "exclude/go1.12.csv",
-)
-
-exclude_test(
- name = "java",
- exclude_file = "exclude/java11.csv",
-)
-
-exclude_test(
- name = "nodejs",
- exclude_file = "exclude/nodejs12.4.0.csv",
-)
-
-exclude_test(
- name = "php",
- exclude_file = "exclude/php7.3.6.csv",
-)
-
-exclude_test(
- name = "python",
- exclude_file = "exclude/python3.7.3.csv",
-)
diff --git a/test/runtimes/defs.bzl b/test/runtimes/defs.bzl
index 3eb494958..399060fa4 100644
--- a/test/runtimes/defs.bzl
+++ b/test/runtimes/defs.bzl
@@ -2,32 +2,69 @@
load("//tools:defs.bzl", "go_test")
-def runtime_test(name, lang, exclude_file, **kwargs):
- go_test(
- name = name,
- srcs = ["runner.go"],
- args = [
- "--lang",
- lang,
- "--image",
- name, # Resolved as images/runtimes/%s.
+def _runtime_test_impl(ctx):
+ # Construct arguments.
+ args = [
+ "--lang",
+ ctx.attr.lang,
+ "--image",
+ ctx.attr.image,
+ ]
+ if ctx.attr.exclude_file:
+ args += [
"--exclude_file",
- "test/runtimes/" + exclude_file,
- ],
- data = [
- exclude_file,
- "//test/runtimes/proctor",
- ],
- defines_main = 1,
+ ctx.files.exclude_file[0].short_path,
+ ]
+
+ # Build a runner.
+ runner = ctx.actions.declare_file("%s-executer" % ctx.label.name)
+ runner_content = "\n".join([
+ "#!/bin/bash",
+ "%s %s $@\n" % (ctx.files._runner[0].short_path, " ".join(args)),
+ ])
+ ctx.actions.write(runner, runner_content, is_executable = True)
+
+ # Return the runner.
+ return [DefaultInfo(
+ executable = runner,
+ runfiles = ctx.runfiles(
+ files = ctx.files._runner + ctx.files.exclude_file + ctx.files._proctor,
+ collect_default = True,
+ collect_data = True,
+ ),
+ )]
+
+_runtime_test = rule(
+ implementation = _runtime_test_impl,
+ attrs = {
+ "image": attr.string(
+ mandatory = False,
+ ),
+ "lang": attr.string(
+ mandatory = True,
+ ),
+ "exclude_file": attr.label(
+ mandatory = False,
+ allow_single_file = True,
+ ),
+ "_runner": attr.label(
+ default = "//test/runtimes/runner:runner",
+ ),
+ "_proctor": attr.label(
+ default = "//test/runtimes/proctor:proctor",
+ ),
+ },
+ test = True,
+)
+
+def runtime_test(name, **kwargs):
+ _runtime_test(
+ name = name,
+ image = name, # Resolved as images/runtimes/%s.
tags = [
"local",
"manual",
],
- deps = [
- "//pkg/log",
- "//pkg/test/dockerutil",
- "//pkg/test/testutil",
- ],
**kwargs
)
diff --git a/test/runtimes/exclude/go1.12.csv b/test/runtimes/exclude_go1.12.csv
index 8c8ae0c5d..8c8ae0c5d 100644
--- a/test/runtimes/exclude/go1.12.csv
+++ b/test/runtimes/exclude_go1.12.csv
diff --git a/test/runtimes/exclude/java11.csv b/test/runtimes/exclude_java11.csv
index c012e5a56..c012e5a56 100644
--- a/test/runtimes/exclude/java11.csv
+++ b/test/runtimes/exclude_java11.csv
diff --git a/test/runtimes/exclude/nodejs12.4.0.csv b/test/runtimes/exclude_nodejs12.4.0.csv
index e7edfa0a5..e7edfa0a5 100644
--- a/test/runtimes/exclude/nodejs12.4.0.csv
+++ b/test/runtimes/exclude_nodejs12.4.0.csv
diff --git a/test/runtimes/exclude/php7.3.6.csv b/test/runtimes/exclude_php7.3.6.csv
index f3606bfe8..f3606bfe8 100644
--- a/test/runtimes/exclude/php7.3.6.csv
+++ b/test/runtimes/exclude_php7.3.6.csv
diff --git a/test/runtimes/exclude/python3.7.3.csv b/test/runtimes/exclude_python3.7.3.csv
index 2b9947212..2b9947212 100644
--- a/test/runtimes/exclude/python3.7.3.csv
+++ b/test/runtimes/exclude_python3.7.3.csv
diff --git a/test/runtimes/runner/BUILD b/test/runtimes/runner/BUILD
new file mode 100644
index 000000000..dc0d5d5b4
--- /dev/null
+++ b/test/runtimes/runner/BUILD
@@ -0,0 +1,22 @@
+load("//tools:defs.bzl", "go_binary", "go_test")
+
+package(licenses = ["notice"])
+
+go_binary(
+ name = "runner",
+ testonly = 1,
+ srcs = ["main.go"],
+ visibility = ["//test/runtimes:__pkg__"],
+ deps = [
+ "//pkg/log",
+ "//pkg/test/dockerutil",
+ "//pkg/test/testutil",
+ ],
+)
+
+go_test(
+ name = "exclude_test",
+ size = "small",
+ srcs = ["exclude_test.go"],
+ library = ":runner",
+)
diff --git a/test/runtimes/exclude_test.go b/test/runtimes/runner/exclude_test.go
index bb4b46630..67c2170c8 100644
--- a/test/runtimes/exclude_test.go
+++ b/test/runtimes/runner/exclude_test.go
@@ -26,7 +26,7 @@ func TestMain(m *testing.M) {
}
// Test that the exclude file parses without error.
-func TestExcludeList(t *testing.T) {
+func TestExcludelist(t *testing.T) {
ex, err := getExcludes()
if err != nil {
t.Fatalf("error parsing exclude file: %v", err)
diff --git a/test/runtimes/runner.go b/test/runtimes/runner/main.go
index 50aca5d69..e230912c9 100644
--- a/test/runtimes/runner.go
+++ b/test/runtimes/runner/main.go
@@ -99,7 +99,7 @@ func getTests(ctx context.Context, d *dockerutil.Container, excludes map[string]
// Get a list of all tests in the image.
list, err := d.Exec(ctx, dockerutil.ExecOpts{}, "/proctor/proctor", "--runtime", *lang, "--list")
if err != nil {
- return nil, fmt.Errorf("docker exec failed: %v\nlogs: %s", err, list)
+ return nil, fmt.Errorf("docker exec failed: %v", err)
}
// Calculate a subset of tests to run corresponding to the current
@@ -166,11 +166,7 @@ func getExcludes() (map[string]struct{}, error) {
if *excludeFile == "" {
return excludes, nil
}
- path, err := testutil.FindFile(*excludeFile)
- if err != nil {
- return nil, err
- }
- f, err := os.Open(path)
+ f, err := os.Open(*excludeFile)
if err != nil {
return nil, err
}