Skip to content

Commit 18ae5a8

Browse files
authored
fix: allow copy_to_directory to have an empty srcs list (#871)
1 parent 3330c38 commit 18ae5a8

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

lib/private/copy_to_directory.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,6 @@ def copy_to_directory_bin_action(
461461
})
462462
file_inputs.append(f.file)
463463

464-
if not file_inputs:
465-
fail("No files to copy")
466-
467464
config = {
468465
"allow_overwrites": allow_overwrites,
469466
"dst": dst.path,

lib/tests/copy_to_directory/BUILD.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,22 @@ diff_test(
449449
file1 = "case_21",
450450
file2 = ":expected_21",
451451
)
452+
453+
# Case 22: empty sources creates an empty directory output
454+
copy_to_directory(
455+
name = "case_22",
456+
srcs = [],
457+
)
458+
459+
copy_to_directory(
460+
name = "expected_22",
461+
srcs = ["dir_expected_22"],
462+
exclude_srcs_patterns = ["**/filter_me_out"],
463+
)
464+
465+
diff_test(
466+
name = "case_22_test",
467+
file1 = "case_22",
468+
file2 = ":expected_22",
469+
tags = ["local"], # seems that the Bazel sandbox has trouble with empty directories
470+
)

lib/tests/copy_to_directory/dir_expected_22/filter_me_out

Whitespace-only changes.

0 commit comments

Comments
 (0)