2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-12-01 07:15:24 +00:00
bazel-lib/lib/tests/tar/asserts.bzl

30 lines
838 B
Python
Raw Normal View History

"Make shorter assertions"
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
# buildifier: disable=function-docstring
def assert_tar_listing(name, actual, expected):
actual_listing = "_{}_listing".format(name)
expected_listing = "_{}_expected".format(name)
native.genrule(
name = actual_listing,
srcs = [actual],
outs = ["_{}.listing".format(name)],
cmd = "$(BSDTAR_BIN) -tvf $(execpath {}) >$@".format(actual),
toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"],
)
write_file(
name = expected_listing,
out = "_{}.expected".format(name),
content = expected + [""],
)
diff_test(
name = name,
file1 = actual_listing,
file2 = expected_listing,
)