Fix error when copy_files source does not exist

Closes #1099

Signed-off-by: Etienne Millon <me@emillon.org>
This commit is contained in:
Etienne Millon 2018-08-10 08:52:39 +00:00
parent 4ecca14b70
commit 4f22d32c68
12 changed files with 47 additions and 0 deletions

View File

@ -4,6 +4,9 @@ next
- Ignore stderr output when trying to find out the number of jobs
available (#1118, fix #1116, @diml)
- Fix error message when the source directory of `copy_files` does not exist.
(#1120, fix #1099, @emillon)
1.1.1 (08/08/2018)
------------------

View File

@ -88,6 +88,9 @@ val files_of : t -> Path.t -> Path.Set.t
(** [true] iff the path is either a directory or a file *)
val exists : t -> Path.t -> bool
(** [true] iff the path is a directory *)
val dir_exists : t -> Path.t -> bool
(** [true] iff the path is a file *)
val file_exists : t -> Path.t -> string -> bool

View File

@ -51,6 +51,12 @@ let copy_files sctx ~dir ~scope ~src_dir (def: Copy_files.t) =
| Error (_pos, msg) ->
Loc.fail (String_with_vars.loc def.glob) "invalid glob: %s" msg
in
let file_tree = Super_context.file_tree sctx in
if not (File_tree.dir_exists file_tree src_in_src) then
Loc.fail
loc
"cannot find directory: %a"
Path.pp src_in_src;
(* add rules *)
let src_in_build = Path.append (SC.context sctx).build_dir src_in_src in
let files = SC.eval_glob sctx ~dir:src_in_build re in

View File

@ -231,6 +231,14 @@
test-cases/github1019
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name github1099)
(deps (package dune) (source_tree test-cases/github1099))
(action
(chdir
test-cases/github1099
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name github20)
(deps (package dune) (source_tree test-cases/github20))
@ -803,6 +811,7 @@
(alias force-test)
(alias gen-opam-install-file)
(alias github1019)
(alias github1099)
(alias github20)
(alias github24)
(alias github25)
@ -898,6 +907,7 @@
(alias findlib-error)
(alias force-test)
(alias github1019)
(alias github1099)
(alias github20)
(alias github24)
(alias github25)

View File

@ -0,0 +1 @@
let () = ()

View File

@ -0,0 +1,3 @@
(copy_files# "no_dir/*")
(executable (name demo))

View File

@ -0,0 +1 @@
(lang dune 1.1)

View File

@ -0,0 +1 @@
let () = ()

View File

@ -0,0 +1,3 @@
(copy_files# "no_dir/*")
(executable (name demo))

View File

@ -0,0 +1 @@
(lang dune 1.1)

View File

@ -0,0 +1,15 @@
If the source directory does not exist, an error message is printed:
$ dune build --root no-dir demo.exe
Entering directory 'no-dir'
File "dune", line 1, characters 13-23:
Error: cannot find directory: no_dir
[1]
This works also is a file exists with the same name:
$ dune build --root file-with-same-name demo.exe
Entering directory 'file-with-same-name'
File "dune", line 1, characters 13-23:
Error: cannot find directory: no_dir
[1]