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/runtimes/defs.bzl | |
parent | c66991ad7de68fd629a1620acad0c8eec2744bac (diff) |
Port runtime tests to use go_test
PiperOrigin-RevId: 321647645
Diffstat (limited to 'test/runtimes/defs.bzl')
-rw-r--r-- | test/runtimes/defs.bzl | 79 |
1 files changed, 21 insertions, 58 deletions
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 ) |