2019-10-09 18:10:08 +00:00
|
|
|
"""Defines a rule for runtime test targets."""
|
|
|
|
|
|
|
|
load("@io_bazel_rules_go//go:def.bzl", "go_test")
|
2019-06-18 08:40:12 +00:00
|
|
|
|
|
|
|
# runtime_test is a macro that will create targets to run the given test target
|
|
|
|
# with different runtime options.
|
2019-09-19 00:03:06 +00:00
|
|
|
def runtime_test(
|
|
|
|
lang,
|
|
|
|
image,
|
2019-09-24 00:42:13 +00:00
|
|
|
shard_count = 50,
|
2019-10-01 19:46:54 +00:00
|
|
|
size = "enormous",
|
|
|
|
blacklist_file = ""):
|
|
|
|
args = [
|
|
|
|
"--lang",
|
|
|
|
lang,
|
|
|
|
"--image",
|
|
|
|
image,
|
|
|
|
]
|
|
|
|
data = [
|
|
|
|
":runner",
|
|
|
|
]
|
|
|
|
if blacklist_file != "":
|
|
|
|
args += ["--blacklist_file", "test/runtimes/" + blacklist_file]
|
|
|
|
data += [blacklist_file]
|
|
|
|
|
2019-10-09 18:10:08 +00:00
|
|
|
# Add a test that the blacklist parses correctly.
|
|
|
|
blacklist_test(lang, blacklist_file)
|
|
|
|
|
2019-09-19 00:03:06 +00:00
|
|
|
sh_test(
|
|
|
|
name = lang + "_test",
|
|
|
|
srcs = ["runner.sh"],
|
2019-10-01 19:46:54 +00:00
|
|
|
args = args,
|
|
|
|
data = data,
|
2019-09-19 00:03:06 +00:00
|
|
|
size = size,
|
|
|
|
shard_count = shard_count,
|
|
|
|
tags = [
|
|
|
|
# Requires docker and runsc to be configured before the test runs.
|
|
|
|
"manual",
|
|
|
|
"local",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-10-09 18:10:08 +00:00
|
|
|
def blacklist_test(lang, blacklist_file):
|
|
|
|
"""Test that a blacklist parses correctly."""
|
|
|
|
go_test(
|
|
|
|
name = lang + "_blacklist_test",
|
|
|
|
embed = [":runner"],
|
|
|
|
srcs = ["blacklist_test.go"],
|
|
|
|
args = ["--blacklist_file", "test/runtimes/" + blacklist_file],
|
|
|
|
data = [blacklist_file],
|
|
|
|
)
|
|
|
|
|
2019-09-19 00:03:06 +00:00
|
|
|
def sh_test(**kwargs):
|
|
|
|
"""Wraps the standard sh_test."""
|
|
|
|
native.sh_test(
|
|
|
|
**kwargs
|
|
|
|
)
|