diff --git a/lib/private/copy_to_directory.bzl b/lib/private/copy_to_directory.bzl index 6a6ca3d..d089f7e 100644 --- a/lib/private/copy_to_directory.bzl +++ b/lib/private/copy_to_directory.bzl @@ -461,9 +461,6 @@ def copy_to_directory_bin_action( }) file_inputs.append(f.file) - if not file_inputs: - fail("No files to copy") - config = { "allow_overwrites": allow_overwrites, "dst": dst.path, diff --git a/lib/tests/copy_to_directory/BUILD.bazel b/lib/tests/copy_to_directory/BUILD.bazel index 9e3db7b..9885171 100644 --- a/lib/tests/copy_to_directory/BUILD.bazel +++ b/lib/tests/copy_to_directory/BUILD.bazel @@ -449,3 +449,22 @@ diff_test( file1 = "case_21", file2 = ":expected_21", ) + +# Case 22: empty sources creates an empty directory output +copy_to_directory( + name = "case_22", + srcs = [], +) + +copy_to_directory( + name = "expected_22", + srcs = ["dir_expected_22"], + exclude_srcs_patterns = ["**/filter_me_out"], +) + +diff_test( + name = "case_22_test", + file1 = "case_22", + file2 = ":expected_22", + tags = ["local"], # seems that the Bazel sandbox has trouble with empty directories +) diff --git a/lib/tests/copy_to_directory/dir_expected_22/filter_me_out b/lib/tests/copy_to_directory/dir_expected_22/filter_me_out new file mode 100644 index 0000000..e69de29