Skip to content

Commit eb94ffa

Browse files
dzbarskyjbedard
andauthored
fix: rename targets to work with symbolic macros (#1020)
--------- Co-authored-by: Jason Bedard <jason+github@jbedard.ca>
1 parent 38aa731 commit eb94ffa

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

lib/expand_template.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def expand_template(name, template, **kwargs):
1616
**kwargs: other named parameters to `expand_template_rule`.
1717
"""
1818
if types.is_list(template):
19-
write_target = "_{}.tmpl".format(name)
19+
write_target = "{}_tmpl".format(name)
2020
write_file(
2121
name = write_target,
2222
out = "{}.txt".format(write_target),

lib/tar.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def tar(name, mtree = "auto", stamp = 0, **kwargs):
102102
stamp: should mtree attribute be stamped
103103
**kwargs: additional named parameters to pass to `tar_rule`
104104
"""
105-
mtree_target = "_{}.mtree".format(name)
105+
mtree_target = "{}_mtree".format(name)
106106
if mtree == "auto":
107107
mtree_spec(
108108
name = mtree_target,

lib/testing.bzl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ def assert_contains(name, actual, expected, size = "small", **kwargs):
1919
**kwargs: additional named arguments for the resulting sh_test
2020
"""
2121

22-
test_sh = "_{}_test.sh".format(name)
23-
expected_file = "_{}_expected.txt".format(name)
22+
test_sh = "{}_test.sh".format(name)
23+
expected_file = "{}_expected.txt".format(name)
2424

2525
write_file(
26-
name = "_%s_expected" % name,
26+
name = "{}_expected".format(name),
2727
out = expected_file,
2828
content = [expected],
2929
)
3030

3131
write_file(
32-
name = "_" + name,
32+
name = "{}_gen".format(name),
3333
out = test_sh,
3434
content = [
3535
"#!/usr/bin/env bash",
@@ -61,22 +61,22 @@ def assert_outputs(name, actual, expected, **kwargs):
6161
fail("expected should be a list of strings, not " + type(expected))
6262

6363
params_file(
64-
name = "_actual_" + name,
64+
name = name + "_actual",
6565
data = [actual],
6666
args = ["$(rootpaths {})".format(actual)],
67-
out = "_{}_outputs.txt".format(name),
67+
out = "{}_outputs.txt".format(name),
6868
)
6969

7070
write_file(
71-
name = "_expected_ " + name,
71+
name = name + "_expected",
7272
content = expected,
73-
out = "_expected_{}.txt".format(name),
73+
out = "{}_expected.txt".format(name),
7474
)
7575

7676
diff_test(
7777
name = name,
78-
file1 = "_expected_ " + name,
79-
file2 = "_actual_" + name,
78+
file1 = name + "_expected",
79+
file2 = name + "_actual",
8080
**kwargs
8181
)
8282

@@ -97,8 +97,8 @@ def assert_json_matches(name, file1, file2, filter1 = ".", filter2 = ".", **kwar
9797
filter2: a jq filter to apply to file2
9898
**kwargs: additional named arguments for the resulting diff_test
9999
"""
100-
name1 = "_{}_jq1".format(name)
101-
name2 = "_{}_jq2".format(name)
100+
name1 = "{}_jq1".format(name)
101+
name2 = "{}_jq2".format(name)
102102
jq(
103103
name = name1,
104104
srcs = [file1],
@@ -154,8 +154,8 @@ def assert_archive_contains(name, archive, expected, type = None, **kwargs):
154154
# -v: only print lines which don't match
155155
grep = "grep -F -x -v -f $actual"
156156

157-
script_name = "_gen_assert_" + name
158-
expected_name = "_expected_" + name
157+
script_name = name + "_gen_assert"
158+
expected_name = name + "_expected"
159159

160160
if types.is_list(expected):
161161
write_file(
@@ -207,8 +207,8 @@ def assert_directory_contains(name, directory, expected, **kwargs):
207207
# -v: only print lines which don't match
208208
grep = "grep -F -x -v -f $actual"
209209

210-
script_name = "_gen_assert_" + name
211-
expected_name = "_expected_" + name
210+
script_name = name + "_gen_assert"
211+
expected_name = name + "_expected"
212212

213213
if types.is_list(expected):
214214
write_file(

lib/tests/tar/asserts.bzl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ load("//lib:diff_test.bzl", "diff_test")
55

66
# buildifier: disable=function-docstring
77
def assert_tar_listing(name, actual, expected):
8-
actual_listing = "_{}_listing".format(name)
9-
expected_listing = "_{}_expected".format(name)
8+
actual_listing = "{}_listing".format(name)
9+
expected_listing = "{}_expected".format(name)
1010

1111
native.genrule(
1212
name = actual_listing,
1313
srcs = [actual],
1414
testonly = True,
15-
outs = ["_{}.listing".format(name)],
15+
outs = ["{}.listing".format(name)],
1616
cmd = "$(BSDTAR_BIN) -tvf $(execpath {}) >$@".format(actual),
1717
toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"],
1818
)
1919

2020
write_file(
2121
name = expected_listing,
2222
testonly = True,
23-
out = "_{}.expected".format(name),
23+
out = "{}.expected".format(name),
2424
content = expected + [""],
2525
newline = "unix",
2626
)
@@ -34,11 +34,11 @@ def assert_tar_listing(name, actual, expected):
3434

3535
# buildifier: disable=function-docstring
3636
def assert_unused_listing(name, actual, expected):
37-
actual_listing = native.package_relative_label("_{}_actual_listing".format(name))
38-
actual_shortnames = native.package_relative_label("_{}_actual_shortnames".format(name))
39-
actual_shortnames_file = native.package_relative_label("_{}.actual_shortnames".format(name))
40-
expected_listing = native.package_relative_label("_{}_expected".format(name))
41-
expected_listing_file = native.package_relative_label("_{}.expected".format(name))
37+
actual_listing = native.package_relative_label("{}_actual_listing".format(name))
38+
actual_shortnames = native.package_relative_label("{}_actual_shortnames".format(name))
39+
actual_shortnames_file = native.package_relative_label("{}.actual_shortnames".format(name))
40+
expected_listing = native.package_relative_label("{}_expected".format(name))
41+
expected_listing_file = native.package_relative_label("{}.expected".format(name))
4242

4343
native.filegroup(
4444
name = actual_listing.name,

0 commit comments

Comments
 (0)