diff --git a/lib/BUILD.bazel b/lib/BUILD.bazel index 20d489f..d689dee 100644 --- a/lib/BUILD.bazel +++ b/lib/BUILD.bazel @@ -99,6 +99,7 @@ bzl_library( name = "tar", srcs = ["tar.bzl"], deps = [ + "//lib:utils", "//lib/private:tar", "@bazel_skylib//lib:types", "@bazel_skylib//rules:write_file", diff --git a/lib/tar.bzl b/lib/tar.bzl index 102701e..de49516 100644 --- a/lib/tar.bzl +++ b/lib/tar.bzl @@ -51,6 +51,7 @@ TODO: load("@bazel_skylib//lib:types.bzl", "types") load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("//lib:utils.bzl", "propagate_common_rule_attributes") load("//lib/private:tar.bzl", _tar = "tar", _tar_lib = "tar_lib") mtree_spec = rule( @@ -102,6 +103,7 @@ def tar(name, mtree = "auto", **kwargs): name = mtree_target, srcs = kwargs["srcs"], out = "{}.txt".format(mtree_target), + **propagate_common_rule_attributes(kwargs) ) elif types.is_list(mtree): write_file( @@ -110,6 +112,7 @@ def tar(name, mtree = "auto", **kwargs): # Ensure there's a trailing newline, as bsdtar will ignore a last line without one content = mtree + [""], newline = "unix", + **propagate_common_rule_attributes(kwargs) ) else: mtree_target = mtree diff --git a/lib/tests/tar/BUILD.bazel b/lib/tests/tar/BUILD.bazel index 6c38dd1..0a8646d 100644 --- a/lib/tests/tar/BUILD.bazel +++ b/lib/tests/tar/BUILD.bazel @@ -223,6 +223,11 @@ copy_directory( tar( name = "dirs", + # Note, testonly should be propagated, proven by + # % bazel query --output=label_kind 'attr("testonly", 1,lib/tests/tar:all)' + # mtree_spec rule //lib/tests/tar:_dirs.mtree + # tar rule //lib/tests/tar:dirs + testonly = True, srcs = glob(["srcdir/**"]) + [ "treeartifact", ], diff --git a/lib/tests/tar/asserts.bzl b/lib/tests/tar/asserts.bzl index ce41678..a35e19a 100644 --- a/lib/tests/tar/asserts.bzl +++ b/lib/tests/tar/asserts.bzl @@ -11,6 +11,7 @@ def assert_tar_listing(name, actual, expected): native.genrule( name = actual_listing, srcs = [actual], + testonly = True, outs = ["_{}.listing".format(name)], cmd = "$(BSDTAR_BIN) -tvf $(execpath {}) >$@".format(actual), toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"], @@ -18,6 +19,7 @@ def assert_tar_listing(name, actual, expected): write_file( name = expected_listing, + testonly = True, out = "_{}.expected".format(name), content = expected + [""], newline = "unix",