fix #697: use to_repository_relative_path in mtree_spec (#696)

* Reproduction for mtree_spec behaving different in other repo

* Fix the bug (but not the test)

* Fix the test

* Rename mtree_spec e2e dir to tar

* Fix bzlmod tests

* Remove unnecessary skylib dependency from e2e repos

* Add e2e tests to matrix

* Replace e2e test with a normal test

To do this, we somewhat abuse the skylib dependency, but that's
probalby OK.
This commit is contained in:
Tobias Schlatter 2023-12-20 20:22:42 +01:00 committed by Greg Magolan
parent 30a5725ef4
commit 2ce45746dd
No known key found for this signature in database
GPG Key ID: 3ED3220F08EA5070
2 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,7 @@
"Implementation of tar rule"
load("//lib:paths.bzl", "to_repository_relative_path")
TAR_TOOLCHAIN_TYPE = "@aspect_bazel_lib//lib:tar_toolchain_type"
# https://www.gnu.org/software/tar/manual/html_section/Compression.html
@ -182,7 +184,7 @@ def _to_rlocation_path(file, workspace):
else:
return workspace + "/" + file.short_path
def _expand(file, expander, transform = lambda f: f.short_path):
def _expand(file, expander, transform = to_repository_relative_path):
expanded = expander.expand(file)
lines = []
for e in expanded:

View File

@ -279,3 +279,21 @@ assert_tar_listing(
"-rwxr-xr-x 0 1000 500 21 Jan 1 2023 lib/tests/tar/src_file",
],
)
# Case 9: Files from a different repository (#697)
# Note: This test uses an exported file from skylib, so we do not need to create
# an additional workspace just for this test.
tar(
name = "tar_different_repo",
srcs = ["@bazel_skylib//:LICENSE"],
out = "9.tar",
)
assert_archive_contains(
name = "test_different_repo",
archive = "9.tar",
expected = [
"LICENSE",
],
)