| "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, tags = []): |
| 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"], |
| tags = tags, |
| ) |
| |
| write_file( |
| name = expected_listing, |
| out = "_{}.expected".format(name), |
| content = expected + [""], |
| tags = tags, |
| ) |
| |
| diff_test( |
| name = name, |
| file1 = actual_listing, |
| file2 = expected_listing, |
| timeout = "short", |
| tags = tags, |
| ) |