forked from google/rpmpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.bzl
More file actions
51 lines (48 loc) · 1.26 KB
/
testing.bzl
File metadata and controls
51 lines (48 loc) · 1.26 KB
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
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
def _diff_test_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._template,
output = ctx.outputs.file,
substitutions = {
"{CMD}": ctx.executable.cmd.short_path,
"{GOLDEN}": ctx.attr.golden,
},
)
diff_test_expand = rule(
attrs = {
"cmd": attr.label(
mandatory = True,
allow_single_file = True,
executable = True,
cfg = "host",
),
"golden": attr.string(
mandatory = True,
),
"_template": attr.label(
default = "//:diff_test.sh",
allow_single_file = True,
),
},
outputs = {"file": "%{name}.sh"},
implementation = _diff_test_impl,
)
def docker_diff(name, base, cmd, golden):
container_image(
name = name,
testonly = True,
base = base,
cmd = cmd,
legacy_run_behavior = False,
)
diff_test_expand(
name = name + "_diff",
cmd = ":%s" % name,
golden = golden,
testonly = True,
)
native.sh_test(
name = name + "_diff_test",
srcs = [":%s_diff" % name],
data = [":%s" % name],
)