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 all commits
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
1 change: 1 addition & 0 deletions doc/changes/10649.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Error out if no files are found when using `copy_files`. (#10649, @jchavarri)
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 def.syntax_version >= (3, 17) && Filename_set.is_empty files
then User_error.raise ~loc [ Pp.textf "Does not match any files" ];
(* 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
25 changes: 25 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,25 @@
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: Does not match any files
[1]

It doesn't error out in older dune lang versions

$ cat >dune-project <<EOF
> (lang dune 3.16)
> EOF

$ dune build
Loading