summaryrefslogtreecommitdiffhomepage
path: root/test/runtimes/build_defs.bzl
blob: 7c11624b45964f67ee6855a266a6d9655375e391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Defines a rule for runtime test targets."""

load("@io_bazel_rules_go//go:def.bzl", "go_test")

# runtime_test is a macro that will create targets to run the given test target
# with different runtime options.
def runtime_test(
        lang,
        image,
        shard_count = 50,
        size = "enormous",
        blacklist_file = ""):
    args = [
        "--lang",
        lang,
        "--image",
        image,
    ]
    data = [
        ":runner",
    ]
    if blacklist_file != "":
        args += ["--blacklist_file", "test/runtimes/" + blacklist_file]
        data += [blacklist_file]

        # Add a test that the blacklist parses correctly.
        blacklist_test(lang, blacklist_file)

    sh_test(
        name = lang + "_test",
        srcs = ["runner.sh"],
        args = args,
        data = data,
        size = size,
        shard_count = shard_count,
        tags = [
            # Requires docker and runsc to be configured before the test runs.
            "manual",
            "local",
        ],
    )

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],
    )

def sh_test(**kwargs):
    """Wraps the standard sh_test."""
    native.sh_test(
        **kwargs
    )