Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy_files: error out if no files found #10649

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dune_rules/simple_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ let copy_files sctx ~dir ~expander ~src_dir (def : Copy_files.t) =
in
Build_system.eval_pred (File_selector.of_glob ~dir glob)
in
if Filename_set.is_empty files
jchavarri marked this conversation as resolved.
Show resolved Hide resolved
then User_error.raise ~loc [ Pp.textf "Cannot find any files to copy" ];
jchavarri marked this conversation as resolved.
Show resolved Hide resolved
(* CR-someday amokhov: We currently traverse the set [files] twice: first, to
add the corresponding rules, and then to convert the files to [targets]. To
do only one traversal we need [Memo.parallel_map_set]. *)
Expand Down
17 changes: 17 additions & 0 deletions test/blackbox-tests/test-cases/copy_files/test7.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Show that copy_files errors out if no files are found

$ mkdir -p target foo
$ cat >dune-project <<EOF
> (lang dune 3.17)
> EOF
$ cat >target/dune <<EOF
> (copy_files
> (files ../foo/*.txt))
> EOF

$ dune build
File "target/dune", line 2, characters 8-20:
2 | (files ../foo/*.txt))
^^^^^^^^^^^^
Error: Cannot find any files to copy
[1]
Loading