Skip to content

Commit

Permalink
copy_files: error out if no files found (ocaml#10649)
Browse files Browse the repository at this point in the history
* copy_files: error out if no files found

Signed-off-by: Javier Chávarri <javier.chavarri@gmail.com>
  • Loading branch information
jchavarri authored and anmonteiro committed Nov 17, 2024
1 parent 121a3c4 commit 83c8dc9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
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

0 comments on commit 83c8dc9

Please sign in to comment.