diff --git a/docs/latest.md b/docs/latest.md
index acd09596..b66d856b 100755
--- a/docs/latest.md
+++ b/docs/latest.md
@@ -99,6 +99,17 @@ pkg_deb(name, archit
+ Create a Debian package.
+
+ This rule produces 2 artifacts: a .deb and a .changes file. The DefaultInfo will
+ include both. If you need downstream rule to specifically depend on only the .deb or
+ .changes file then you can use `filegroup` to select distinct output groups.
+
+ **OutputGroupInfo**
+ - `out` the Debian package or a symlink to the actual package.
+ - `deb` the package with any precise file name created with `package_file_name`.
+ - `changes` the .changes file.
+
**ATTRIBUTES**
@@ -170,11 +181,12 @@ find_system_rpmbuild(name="rules_pkg_rpmbuild")
pkg_rpm(name, architecture, binary_payload_compression, changelog, conflicts, debug, description,
- description_file, group, license, package_file_name, package_name, package_variables,
- post_scriptlet, post_scriptlet_file, postun_scriptlet, postun_scriptlet_file, pre_scriptlet,
- pre_scriptlet_file, preun_scriptlet, preun_scriptlet_file, provides, release, release_file,
- requires, requires_contextual, rpmbuild_path, source_date_epoch, source_date_epoch_file,
- spec_template, srcs, summary, url, version, version_file)
+ description_file, group, license, obsoletes, package_file_name, package_name,
+ package_variables, post_scriptlet, post_scriptlet_file, postun_scriptlet,
+ postun_scriptlet_file, pre_scriptlet, pre_scriptlet_file, preun_scriptlet,
+ preun_scriptlet_file, provides, release, release_file, requires, requires_contextual,
+ rpmbuild_path, source_date_epoch, source_date_epoch_file, spec_template, srcs, summary, url,
+ version, version_file)
Creates an RPM format package via `pkg_filegroup` and friends.
@@ -205,6 +217,14 @@ Creates an RPM format package via `pkg_filegroup` and friends.
Is the equivalent to `%config(missingok, noreplace)` in the `%files` list.
+ This rule produces 2 artifacts: an .rpm and a .changes file. The DefaultInfo will
+ include both. If you need downstream rule to specifically depend on only the .rpm or
+ .changes file then you can use `filegroup` to select distinct output groups.
+
+ **OutputGroupInfo**
+ - `out` the RPM or a symlink to the actual package.
+ - `rpm` the package with any precise file name created with `package_file_name`.
+ - `changes` the .changes file.
**ATTRIBUTES**
@@ -216,12 +236,13 @@ Creates an RPM format package via `pkg_filegroup` and friends.
| architecture | Package architecture.
This currently sets the BuildArch
tag, which influences the output architecture of the package.
Typically, BuildArch
only needs to be set when the package is known to be cross-platform (e.g. written in an interpreted language), or, less common, when it is known that the application is only valid for specific architectures.
When no attribute is provided, this will default to your host's architecture. This is usually what you want. | String | optional | "" |
| binary_payload_compression | Compression mode used for this RPM
Must be a form that rpmbuild(8)
knows how to process, which will depend on the version of rpmbuild
in use. The value corresponds to the %_binary_payload
macro and is set on the rpmbuild(8)
command line if provided.
Some examples of valid values (which may not be supported on your system) can be found [here](https://git.io/JU9Wg). On CentOS systems (also likely Red Hat and Fedora), you can find some supported values by looking for %_binary_payload
in /usr/lib/rpm/macros
. Other systems have similar files and configurations.
If not provided, the compression mode will be computed by rpmbuild
itself. Defaults may vary per distribution or build of rpm
; consult the relevant documentation for more details.
WARNING: Bazel is currently not aware of action threading requirements for non-test actions. Using threaded compression may result in overcommitting your system. | String | optional | "" |
| changelog | - | Label | optional | None |
-| conflicts | List of capabilities that conflict with this package when it is installed.
Corresponds to the "Conflicts" preamble tag.
See also: https://rpm.org/user_doc/dependencies.html | List of strings | optional | [] |
+| conflicts | List of capabilities that conflict with this package when it is installed.
Corresponds to the "Conflicts" preamble tag.
See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| debug | Debug the RPM helper script and RPM generation | Boolean | optional | False |
| description | Multi-line description of this package, corresponds to RPM %description.
Exactly one of description
or description_file
must be provided. | String | optional | "" |
| description_file | File containing a multi-line description of this package, corresponds to RPM %description. | Label | optional | None |
| group | Optional; RPM "Group" tag.
NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag. Other distributions may require it, but it is harmless in any case. | String | optional | "" |
| license | RPM "License" tag.
The software license for the code distributed in this package.
The underlying RPM builder requires you to put something here; if your package is not going to be distributed, feel free to set this to something like "Internal". | String | required | |
+| obsoletes | List of rpm capability expressions that this package obsoletes.
Corresponds to the "Obsoletes" preamble tag.
See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| package_file_name | See 'Common Attributes' in the rules_pkg reference.
If this is not provided, the package file given a NVRA-style (name-version-release.arch) output, which is preferred by most RPM repositories. | String | optional | "" |
| package_name | Optional; RPM name override.
If not provided, the name
attribute of this rule will be used instead.
This influences values like the spec file name. | String | optional | "" |
| package_variables | See 'Common Attributes' in the rules_pkg reference | Label | optional | None |
@@ -233,11 +254,11 @@ Creates an RPM format package via `pkg_filegroup` and friends.
| pre_scriptlet_file | File containing the RPM %pre
scriptlet | Label | optional | None |
| preun_scriptlet | RPM %preun
scriptlet. Currently only allowed to be a shell script.
preun_scriptlet
and preun_scriptlet_file
are mutually exclusive. | String | optional | "" |
| preun_scriptlet_file | File containing the RPM %preun
scriptlet | Label | optional | None |
-| provides | List of rpm capabilities that this package provides.
Corresponds to the "Provides" preamble tag.
See also: https://rpm.org/user_doc/dependencies.html | List of strings | optional | [] |
+| provides | List of rpm capabilities that this package provides.
Corresponds to the "Provides" preamble tag.
See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| release | RPM "Release" tag
Exactly one of release
or release_file
must be provided. | String | optional | "" |
| release_file | File containing RPM "Release" tag. | Label | optional | None |
-| requires | List of rpm capability expressions that this package requires.
Corresponds to the "Requires" preamble tag.
See also: https://rpm.org/user_doc/dependencies.html | List of strings | optional | [] |
-| requires_contextual | Contextualized requirement specifications
This is a map of various properties (often scriptlet types) to capability name specifications, e.g.:
python {"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}
Requires(pre): GConf2 Requires(post): GConf2 Requires(postun): GConf2
pre
- post
- preun
- postun
- pretrans
- posttrans
requires
attribute instead.pkg_rpm
does not check if the keys of this dictionary are acceptable to rpm(8)
. | Dictionary: String -> List of strings | optional | {} |
+| requires | List of rpm capability expressions that this package requires.python {"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}
Requires(pre): GConf2 Requires(post): GConf2 Requires(postun): GConf2
pre
- post
- preun
- postun
- pretrans
- posttrans
requires
attribute instead.pkg_rpm
does not check if the keys of this dictionary are acceptable to rpm(8)
. | Dictionary: String -> List of strings | optional | {} |
| rpmbuild_path | Path to a rpmbuild
binary. Deprecated in favor of the rpmbuild toolchain | String | optional | "" |
| source_date_epoch | Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds%clamp_mtime_to_source_date_epoch
in the subordinate call to rpmbuild
to facilitate more consistent in-RPM file timestamps.%clamp_mtime_to_source_date_epoch
in the subordinate call to rpmbuild
to facilitate more consistent in-RPM file timestamps. | Label | optional | None |
@@ -259,10 +280,11 @@ Rules for making .tar files.
## pkg_tar
-pkg_tar(name, compressor, compressor_args, deps, empty_dirs, empty_files, extension, files, - include_runfiles, mode, modes, mtime, out, owner, ownername, ownernames, owners, - package_dir, package_dir_file, package_file_name, package_variables, portable_mtime, - private_stamp_detect, remap_paths, srcs, stamp, strip_prefix, symlinks) +pkg_tar(name, allow_duplicates_with_different_content, compressor, compressor_args, deps, + empty_dirs, empty_files, extension, files, include_runfiles, mode, modes, mtime, out, + owner, ownername, ownernames, owners, package_dir, package_dir_file, package_file_name, + package_variables, portable_mtime, private_stamp_detect, remap_paths, srcs, stamp, + strip_prefix, symlinks)@@ -273,6 +295,7 @@ pkg_tar(name, compress | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| allow_duplicates_with_different_content | If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code. | Boolean | optional | True | | compressor | External tool which can compress the archive. | Label | optional | None | | compressor_args | Arg list for
compressor
. | String | optional | "" |
| deps | tar files which will be unpacked and repacked into the archive. | List of labels | optional | [] |
@@ -280,12 +303,12 @@ pkg_tar(name, compress
| empty_files | - | List of strings | optional | [] |
| extension | - | String | optional | "tar" |
| files | Obsolete. Do not use. | Dictionary: Label -> String | optional | {} |
-| include_runfiles | - | Boolean | optional | False |
+| include_runfiles | Include runfiles for executables. These appear as they would in bazel-bin.For example: 'path/to/myprog.runfiles/path/to/my_data.txt'. | Boolean | optional | False |
| mode | - | String | optional | "0555" |
| modes | - | Dictionary: String -> String | optional | {} |
| mtime | - | Integer | optional | -1 |
| out | - | Label | required | |
-| owner | Default numeric owner.group to apply to files when not set via pkg_attribures. | String | optional | "0.0" |
+| owner | Default numeric owner.group to apply to files when not set via pkg_attributes. | String | optional | "0.0" |
| ownername | - | String | optional | "." |
| ownernames | - | Dictionary: String -> String | optional | {} |
| owners | - | Dictionary: String -> String | optional | {} |
@@ -312,8 +335,9 @@ Zip archive creation rule and associated logic.
## pkg_zip
-pkg_zip(name, compression_level, compression_type, mode, out, package_dir, package_file_name, - package_variables, private_stamp_detect, srcs, stamp, strip_prefix, timestamp) +pkg_zip(name, allow_duplicates_with_different_content, compression_level, compression_type, + include_runfiles, mode, out, package_dir, package_file_name, package_variables, + private_stamp_detect, srcs, stamp, strip_prefix, timestamp)@@ -324,8 +348,10 @@ pkg_zip(name, c | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| allow_duplicates_with_different_content | If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code. | Boolean | optional | True | | compression_level | The compression level to use, 1 is the fastest, 9 gives the smallest results. 0 skips compression, depending on the method used | Integer | optional | 6 | | compression_type | The compression to use. Note that lzma and bzip2 might not be supported by all readers. The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED | String | optional | "deflated" | +| include_runfiles | See standard attributes. | Boolean | optional | False | | mode | The default mode for all files in the archive. | String | optional | "0555" | | out | output file name. Default: name + ".zip". | Label | required | | | package_dir | Prefix to be prepend to all paths written. The name may contain variables, same as [package_file_name](#package_file_name) | String | optional | "/" | diff --git a/pkg/private/pkg_files.bzl b/pkg/private/pkg_files.bzl index 769fffb8..603e2c28 100644 --- a/pkg/private/pkg_files.bzl +++ b/pkg/private/pkg_files.bzl @@ -75,6 +75,8 @@ _MappingContext = provider( "include_runfiles": "bool: include runfiles", "strip_prefix": "strip_prefix", + "path_mapper": "function to map destination paths", + # Defaults "default_mode": "Default mode to apply to file without a mode setting", "default_user": "Default user name to apply to file without a user", @@ -91,7 +93,9 @@ def create_mapping_context_from_ctx( allow_duplicates_with_different_content = None, strip_prefix = None, include_runfiles = None, - default_mode = None): + default_mode = None, + path_mapper = None + ): """Construct a MappingContext. Args: See the provider definition. @@ -116,6 +120,7 @@ def create_mapping_context_from_ctx( strip_prefix = strip_prefix, include_runfiles = include_runfiles, default_mode = default_mode, + path_mapper = path_mapper or (lambda x: x), # TODO(aiuto): allow these to be passed in as needed. But, before doing # that, explore defauilt_uid/gid as 0 rather than None default_user = "", @@ -340,7 +345,7 @@ def add_label_list(mapping_context, srcs): Args: mapping_context: (r/w) a MappingContext - srcs: List of source objects. + srcs: List of source objects """ # Compute the relative path @@ -390,12 +395,13 @@ def add_from_default_info( the_executable = get_my_executable(src) all_files = src[DefaultInfo].files.to_list() for f in all_files: - d_path = dest_path(f, data_path, data_path_without_prefix) + d_path = mapping_context.path_mapper( + dest_path(f, data_path, data_path_without_prefix)) if f.is_directory: add_tree_artifact( mapping_context.content_map, - d_path, - f, + dest_path = d_path, + src = f, origin = src.label, mode = mapping_context.default_mode, user = mapping_context.default_user, @@ -415,7 +421,16 @@ def add_from_default_info( if include_runfiles: runfiles = src[DefaultInfo].default_runfiles if runfiles: - base_path = d_path + ".runfiles" + mapping_context.file_deps.append(runfiles.files) + + # Computing the runfiles root is subtle. It should be based off of + # the executable, but that is not always obvious. When in doubt, + # the first file of DefaultInfo.files should be the right target. + base_file = the_executable or all_files[0] + base_file_path = mapping_context.path_mapper( + dest_path(base_file, data_path, data_path_without_prefix)) + base_path = base_file_path + ".runfiles" + for rf in runfiles.files.to_list(): d_path = base_path + "/" + rf.short_path fmode = "0755" if rf == the_executable else mapping_context.default_mode diff --git a/pkg/private/tar/tar.bzl b/pkg/private/tar/tar.bzl index 1831033b..963cb5a1 100644 --- a/pkg/private/tar/tar.bzl +++ b/pkg/private/tar/tar.bzl @@ -13,17 +13,15 @@ # limitations under the License. """Rules for making .tar files.""" -load("//pkg:path.bzl", "compute_data_path", "dest_path") load("//pkg:providers.bzl", "PackageVariablesInfo") load( "//pkg/private:pkg_files.bzl", "add_directory", "add_empty_file", + "add_label_list", "add_single_file", "add_symlink", - "add_tree_artifact", "create_mapping_context_from_ctx", - "process_src", "write_manifest", ) load("//pkg/private:util.bzl", "setup_output_files", "substitute_package_variables") @@ -58,16 +56,8 @@ def _pkg_tar_impl(ctx): # Files needed by rule implementation at runtime files = [] - outputs, output_file, _ = setup_output_files(ctx) - # Compute the relative path - data_path = compute_data_path(ctx.label, ctx.attr.strip_prefix) - data_path_without_prefix = compute_data_path(ctx.label, ".") - - # Find a list of path remappings to apply. - remap_paths = ctx.attr.remap_paths - # Start building the arguments. args = ctx.actions.args() args.add("--output", output_file.path) @@ -112,53 +102,36 @@ def _pkg_tar_impl(ctx): args.add("--mtime", "%d" % ctx.attr.mtime) if ctx.attr.portable_mtime: args.add("--mtime", "portable") + if ctx.attr.modes: + for key in ctx.attr.modes: + args.add("--modes", "%s=%s" % (_quote(key), ctx.attr.modes[key])) + if ctx.attr.owners: + for key in ctx.attr.owners: + args.add("--owners", "%s=%s" % (_quote(key), ctx.attr.owners[key])) + if ctx.attr.ownernames: + for key in ctx.attr.ownernames: + args.add( + "--owner_names", + "%s=%s" % (_quote(key), ctx.attr.ownernames[key]), + ) # Now we begin processing the files. + path_mapper = None + if ctx.attr.remap_paths: + path_mapper = lambda path: _remap(ctx.attr.remap_paths, path) + mapping_context = create_mapping_context_from_ctx( ctx, label = ctx.label, - include_runfiles = False, # TODO(aiuto): ctx.attr.include_runfiles, + include_runfiles = ctx.attr.include_runfiles, strip_prefix = ctx.attr.strip_prefix, - default_mode = ctx.attr.mode, + # build_tar does the default modes. Consider moving attribute mapping + # into mapping_context. + default_mode = None, + path_mapper = path_mapper, ) - # Start with all the pkg_* inputs - for src in ctx.attr.srcs: - if not process_src( - mapping_context, - src = src, - origin = src.label, - ): - src_files = src[DefaultInfo].files.to_list() - if ctx.attr.include_runfiles: - runfiles = src[DefaultInfo].default_runfiles - if runfiles: - mapping_context.file_deps.append(runfiles.files) - src_files.extend(runfiles.files.to_list()) - - # Add in the files of srcs which are not pkg_* types - for f in src_files: - d_path = dest_path(f, data_path, data_path_without_prefix) - - # Note: This extra remap is the bottleneck preventing this - # large block from being a utility method as shown below. - # Should we disallow mixing pkg_files in srcs with remap? - # I am fine with that if it makes the code more readable. - dest = _remap(remap_paths, d_path) - if f.is_directory: - add_tree_artifact(mapping_context.content_map, dest, f, src.label) - else: - # Note: This extra remap is the bottleneck preventing this - # large block from being a utility method as shown below. - # Should we disallow mixing pkg_files in srcs with remap? - # I am fine with that if it makes the code more readable. - dest = _remap(remap_paths, d_path) - add_single_file(mapping_context, dest, f, src.label) - - # TODO(aiuto): I want the code to look like this, but we don't have lambdas. - # transform_path = lambda f: _remap( - # remap_paths, dest_path(f, data_path, data_path_without_prefix)) - # add_label_list(mapping_context, ctx.attr.srcs, transform_path) + add_label_list(mapping_context, srcs = ctx.attr.srcs) # The files attribute is a map of labels to destinations. We can add them # directly to the content map. @@ -174,18 +147,6 @@ def _pkg_tar_impl(ctx): target.label, ) - if ctx.attr.modes: - for key in ctx.attr.modes: - args.add("--modes", "%s=%s" % (_quote(key), ctx.attr.modes[key])) - if ctx.attr.owners: - for key in ctx.attr.owners: - args.add("--owners", "%s=%s" % (_quote(key), ctx.attr.owners[key])) - if ctx.attr.ownernames: - for key in ctx.attr.ownernames: - args.add( - "--owner_names", - "%s=%s" % (_quote(key), ctx.attr.ownernames[key]), - ) for empty_file in ctx.attr.empty_files: add_empty_file(mapping_context, empty_file, ctx.label) for empty_dir in ctx.attr.empty_dirs or []: @@ -289,7 +250,10 @@ pkg_tar_impl = rule( "extension": attr.string(default = "tar"), "symlinks": attr.string_dict(), "empty_files": attr.string_list(), - "include_runfiles": attr.bool(), + "include_runfiles": attr.bool( + doc = ("""Include runfiles for executables. These appear as they would in bazel-bin.""" + + """For example: 'path/to/myprog.runfiles/path/to/my_data.txt'."""), + ), "empty_dirs": attr.string_list(), "remap_paths": attr.string_dict(), "compressor": attr.label( diff --git a/pkg/verify_archive_test_main.py.tpl b/pkg/verify_archive_test_main.py.tpl index 681bb0a7..f831ecb5 100644 --- a/pkg/verify_archive_test_main.py.tpl +++ b/pkg/verify_archive_test_main.py.tpl @@ -50,6 +50,8 @@ class VerifyArchiveTest(unittest.TestCase): Args: min_size: The minimum number of targets we expect. """ + if min_size <= 0: + return actual_size = len(self.paths) self.assertGreaterEqual( len(self.paths), @@ -63,7 +65,7 @@ class VerifyArchiveTest(unittest.TestCase): Args: max_size: The maximum number of targets we expect. """ - if max_size < 0: + if max_size <= 0: return actual_size = len(self.paths) self.assertLessEqual( @@ -78,7 +80,7 @@ class VerifyArchiveTest(unittest.TestCase): if path in plain_patterns: plain_patterns.remove(path) if len(plain_patterns) > 0: - self.fail('These required paths were not found: %s' % ','.join(plain_patterns)) + self.fail('These required paths were not found: %s' % ','.join(plain_patterns) + ' in [%s]' % ','.join(self.paths)) def check_must_not_contain(self, must_not_contain): plain_patterns = set(must_not_contain) diff --git a/tests/BUILD b/tests/BUILD index 493e8bfe..f6ab2b01 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -116,7 +116,7 @@ cc_library( cc_binary( name = "an_executable", srcs = ["foo.cc"], - data = ["BUILD"], + data = ["foo.cc"], deps = [ ":liba", ":libb", diff --git a/tests/mappings/executable.manifest.golden b/tests/mappings/executable.manifest.golden index ee86633b..92195549 100644 --- a/tests/mappings/executable.manifest.golden +++ b/tests/mappings/executable.manifest.golden @@ -1,5 +1,5 @@ [ -{"dest":"an_executable.runfiles/tests/BUILD","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/BUILD","type":"file","uid":null,"user":null}, +{"dest":"an_executable.runfiles/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null}, {"dest":"an_executable.runfiles/tests/an_executable","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable","type":"file","uid":null,"user":null}, {"dest":"an_executable.runfiles/tests/testdata/hello.txt","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/testdata/hello.txt","type":"file","uid":null,"user":null}, {"dest":"an_executable","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable","type":"file","uid":null,"user":null}, diff --git a/tests/mappings/executable.manifest.windows.golden b/tests/mappings/executable.manifest.windows.golden index d853c0d4..150f477e 100644 --- a/tests/mappings/executable.manifest.windows.golden +++ b/tests/mappings/executable.manifest.windows.golden @@ -1,5 +1,5 @@ [ -{"dest":"an_executable.exe.runfiles/tests/BUILD","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/BUILD","type":"file","uid":null,"user":null}, +{"dest":"an_executable.exe.runfiles/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null}, {"dest":"an_executable.exe.runfiles/tests/an_executable.exe","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable.exe","type":"file","uid":null,"user":null}, {"dest":"an_executable.exe.runfiles/tests/testdata/hello.txt","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/testdata/hello.txt","type":"file","uid":null,"user":null}, {"dest":"an_executable.exe","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable.exe","type":"file","uid":null,"user":null}, diff --git a/tests/tar/BUILD b/tests/tar/BUILD index cecb5a8e..7b16a09f 100644 --- a/tests/tar/BUILD +++ b/tests/tar/BUILD @@ -323,16 +323,41 @@ fake_artifact( name = "a_program", files = ["//tests:testdata/executable.sh"], runfiles = ["BUILD"], + executable = True, ) pkg_tar( name = "test-tar-with-runfiles", srcs = [ ":a_program", + "//tests:an_executable", ], include_runfiles = True, ) +verify_archive_test( + name = "runfiles_test", + target = ":test-tar-with-runfiles", + must_contain = [ + "a_program", + "a_program.runfiles/tests/tar/BUILD", + "executable.sh", + ] + select({ + "@platforms//os:windows": [ + "an_executable.exe", + "an_executable.exe.runfiles/tests/foo.cc", + "an_executable.exe.runfiles/tests/an_executable.exe", + "an_executable.exe.runfiles/tests/testdata/hello.txt", + ], + "//conditions:default": [ + "an_executable", + "an_executable.runfiles/tests/foo.cc", + "an_executable.runfiles/tests/an_executable", + "an_executable.runfiles/tests/testdata/hello.txt", + ] + }), +) + pkg_tar( name = "test_tar_leading_dotslash", srcs = [ @@ -364,7 +389,6 @@ py_test( ":test-tar-strip_prefix-substring.tar", ":test-tar-tree-artifact", ":test-tar-tree-artifact-noroot", - ":test-tar-with-runfiles", ":test-tree-input-with-strip-prefix", ":test_tar_leading_dotslash", ":test_tar_package_dir_substitution.tar", diff --git a/tests/tar/pkg_tar_test.py b/tests/tar/pkg_tar_test.py index 3bf1254b..d18c49c0 100644 --- a/tests/tar/pkg_tar_test.py +++ b/tests/tar/pkg_tar_test.py @@ -244,14 +244,6 @@ def test_tar_with_tree_artifact(self): self.assertTarFileContent('test-tar-tree-artifact-noroot.tar', noroot_content) - def test_tar_with_runfiles(self): - content = [ - {'name': 'BUILD' }, - {'name': 'a_program' }, - {'name': 'executable.sh' }, - ] - self.assertTarFileContent('test-tar-with-runfiles.tar', content) - def test_tar_leading_dotslash(self): content = [ {'name': './loremipsum.txt'},