diff options
author | Ayush Ranjan <ayushranjan@google.com> | 2020-07-16 14:35:39 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-16 14:37:13 -0700 |
commit | e6894cb99fe4c6e8599354bf5bc6a72a79b63fd3 (patch) | |
tree | f3a998132d1c89e45f7caf3eeb53f62e00aa5ca0 /test | |
parent | c66991ad7de68fd629a1620acad0c8eec2744bac (diff) |
Port runtime tests to use go_test
PiperOrigin-RevId: 321647645
Diffstat (limited to 'test')
-rw-r--r-- | test/runtimes/BUILD | 58 | ||||
-rw-r--r-- | test/runtimes/defs.bzl | 79 | ||||
-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/exclude_test.go (renamed from test/runtimes/runner/exclude_test.go) | 2 | ||||
-rw-r--r-- | test/runtimes/runner.go (renamed from test/runtimes/runner/main.go) | 8 | ||||
-rw-r--r-- | test/runtimes/runner/BUILD | 22 |
10 files changed, 79 insertions, 90 deletions
diff --git a/test/runtimes/BUILD b/test/runtimes/BUILD index f98d02e00..aeefa8f56 100644 --- a/test/runtimes/BUILD +++ b/test/runtimes/BUILD @@ -1,38 +1,82 @@ -load("//test/runtimes:defs.bzl", "runtime_test") +load("//test/runtimes:defs.bzl", "exclude_test", "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 = 10, + shard_count = 5, ) 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 dc3667f05..3eb494958 100644 --- a/test/runtimes/defs.bzl +++ b/test/runtimes/defs.bzl @@ -2,69 +2,32 @@ load("//tools:defs.bzl", "go_test") -def _runtime_test_impl(ctx): - # Construct arguments. - args = [ - "--lang", - ctx.attr.lang, - "--image", - ctx.attr.image, - ] - if ctx.attr.exclude_file: - args += [ - "--exclude_file", - 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( +def runtime_test(name, lang, exclude_file, **kwargs): + go_test( name = name, - image = name, # Resolved as images/runtimes/%s. + srcs = ["runner.go"], + args = [ + "--lang", + lang, + "--image", + name, # Resolved as images/runtimes/%s. + "--exclude_file", + "test/runtimes/" + exclude_file, + ], + data = [ + exclude_file, + "//test/runtimes/proctor", + ], + defines_main = 1, 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/exclude_test.go b/test/runtimes/exclude_test.go index 67c2170c8..bb4b46630 100644 --- a/test/runtimes/runner/exclude_test.go +++ b/test/runtimes/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/main.go b/test/runtimes/runner.go index e230912c9..50aca5d69 100644 --- a/test/runtimes/runner/main.go +++ b/test/runtimes/runner.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", err) + return nil, fmt.Errorf("docker exec failed: %v\nlogs: %s", err, list) } // Calculate a subset of tests to run corresponding to the current @@ -166,7 +166,11 @@ func getExcludes() (map[string]struct{}, error) { if *excludeFile == "" { return excludes, nil } - f, err := os.Open(*excludeFile) + path, err := testutil.FindFile(*excludeFile) + if err != nil { + return nil, err + } + f, err := os.Open(path) if err != nil { return nil, err } diff --git a/test/runtimes/runner/BUILD b/test/runtimes/runner/BUILD deleted file mode 100644 index dc0d5d5b4..000000000 --- a/test/runtimes/runner/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -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", -) |