From b70ccefb2107deacf63322152820ceb3ca1b36a7 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 22 Jan 2019 17:53:10 +0000 Subject: [PATCH 1/2] Add reproduction case for #1772 Signed-off-by: Jeremie Dimino --- test/blackbox-tests/test-cases/promote/run.t | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/blackbox-tests/test-cases/promote/run.t b/test/blackbox-tests/test-cases/promote/run.t index 935f4079cf3..3b4f8454eb1 100644 --- a/test/blackbox-tests/test-cases/promote/run.t +++ b/test/blackbox-tests/test-cases/promote/run.t @@ -60,3 +60,38 @@ Test single file promotion $ dune promote x y Warning: Nothing to promote for x. Warning: Nothing to promote for y. + +Reproduction case for #1772 +--------------------------- + + $ printf a > x + $ printf a > y + $ dune build --display short @blah @blah2 + File "x", line 1, characters 0-0: + Files _build/default/x and _build/default/x.gen differ. + File "y", line 1, characters 0-0: + Files _build/default/y and _build/default/y.gen differ. + [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] From 117aabf3f9e92e08724ef5cfcf33928e71ca5c3f Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 22 Jan 2019 17:59:16 +0000 Subject: [PATCH 2/2] Improve the behaviour of `dune promote` when files are missing Fixes #1772 Signed-off-by: Jeremie Dimino --- CHANGES.md | 3 +++ src/promotion.ml | 15 +++++++++---- test/blackbox-tests/test-cases/promote/run.t | 23 ++------------------ 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0fe4bd746ba..ce6fb604786 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/src/promotion.ml b/src/promotion.ml index b1e2c5139cc..ab48c166c88 100644 --- a/src/promotion.ml +++ b/src/promotion.ml @@ -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 () = diff --git a/test/blackbox-tests/test-cases/promote/run.t b/test/blackbox-tests/test-cases/promote/run.t index 3b4f8454eb1..2e9edf46e9e 100644 --- a/test/blackbox-tests/test-cases/promote/run.t +++ b/test/blackbox-tests/test-cases/promote/run.t @@ -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.