Skip to content

Commit

Permalink
Improve the behaviour of dune promote when files are missing
Browse files Browse the repository at this point in the history
Fixes #1772

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
  • Loading branch information
jeremiedimino committed Jan 24, 2019
1 parent 11bf7eb commit c2bbc87
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ unreleased
`.merlin` with `S`-directives pointed to original source locations and thus
allowing merlin to see those.

- Improve the behavior of `dune promote` when the files to be promoted have been
deleted. (#1775, fixes #1772, @diml)

- unstable-fmt: preserve comments (#1766, @emillon)

1.6.2 (05/12/2018)
Expand Down
15 changes: 11 additions & 4 deletions src/promotion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ module File = struct
let register t = db := t :: !db

let promote { src; dst } =
Errors.print_to_console (Format.sprintf "Promoting %s to %s.@."
(Path.to_string_maybe_quoted src)
(Path.to_string_maybe_quoted dst));
Io.copy_file ~src ~dst ()
let src_exists = Path.exists src in
Errors.print_to_console
(Format.sprintf
(if src_exists then
"Promoting %s to %s.@."
else
"Skipping promotion of %s to %s as the file is missing.@.")
(Path.to_string_maybe_quoted src)
(Path.to_string_maybe_quoted dst));
if src_exists then
Io.copy_file ~src ~dst ()
end

let clear_cache () =
Expand Down
23 changes: 2 additions & 21 deletions test/blackbox-tests/test-cases/promote/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,5 @@ Reproduction case for #1772
[1]
$ rm -f _build/default/x.gen
$ dune promote
Promoting _build/default/x.gen to x.
Error: exception Sys_error("_build/default/x.gen: No such file or directory")
Backtrace:
Raised by primitive operation at file "stdlib.ml", line 390, characters 28-54
Called from file "src/stdune/io.ml", line 74, characters 17-37
Called from file "src/promotion.ml", line 86, characters 6-31
Called from file "map.ml", line 295, characters 20-25
Called from file "src/promotion.ml", line 93, characters 4-44
Called from file "src/promotion.ml", line 124, characters 11-41
Called from file "vendor/cmdliner/src/cmdliner_term.ml", line 25, characters 19-24
Called from file "vendor/cmdliner/src/cmdliner.ml", line 116, characters 32-39
Called from file "vendor/cmdliner/src/cmdliner.ml", line 146, characters 18-36
Called from file "vendor/cmdliner/src/cmdliner.ml", line 261, characters 22-48
Called from file "bin/main.ml", line 177, characters 10-51

I must not segfault. Uncertainty is the mind-killer. Exceptions are
the little-death that brings total obliteration. I will fully express
my cases. Execution will pass over me and through me. And when it
has gone past, I will unwind the stack along its path. Where the
cases are handled there will be nothing. Only I will remain.
[1]
Skipping promotion of _build/default/x.gen to x as the file is missing.
Promoting _build/default/y.gen to y.

0 comments on commit c2bbc87

Please sign in to comment.