Skip to content

Commit

Permalink
fix: Not all runfiles are single files (#860)
Browse files Browse the repository at this point in the history
* fix: Not all runfiles are single files

Handle cases where the defaultInfo file is a directory

* Add test case
  • Loading branch information
ewianda authored Apr 29, 2024
1 parent 21e1ccc commit 9616a33
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/private/pkg_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def add_from_default_info(
_check_dest(mapping_context.content_map, d_path, rf, src.label, mapping_context.allow_duplicates_with_different_content)
mapping_context.content_map[d_path] = _DestFile(
src = rf,
entry_type = ENTRY_IS_FILE,
entry_type = ENTRY_IS_TREE if rf.is_directory else ENTRY_IS_FILE,
origin = src.label,
mode = fmode,
user = mapping_context.default_user,
Expand Down
38 changes: 38 additions & 0 deletions tests/tar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -710,3 +710,41 @@ verify_archive_test(
"new/base/something/this": "that",
},
)
fake_artifact(
name = "program_with_dir_runfiles",
files = ["//tests:testdata/executable.sh"],
runfiles = [
":generate_tree",
],
)

pkg_tar(
name = "program_with_dir_runfiles_tar",
srcs = [
":program_with_dir_runfiles",
],
include_runfiles = True,
)

verify_archive_test(
name = "program_with_dir_runfiles_test",
must_contain = [
"program_with_dir_runfiles.runfiles",
"program_with_dir_runfiles.runfiles/_main",
"program_with_dir_runfiles.runfiles/_main/tests",
"program_with_dir_runfiles.runfiles/_main/tests/tar",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a/a",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a/b",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a/b/c",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/c",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/c/d",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/d",
"program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/e",
"executable.sh",
"program_with_dir_runfiles",
],
target = ":program_with_dir_runfiles_tar",
)

0 comments on commit 9616a33

Please sign in to comment.