8000 feature: add --stop-on-first-error CLI option by Alizter · Pull Request #8400 · ocaml/dune · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feature: add --stop-on-first-error CLI option #8400

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

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
10 changes: 10 additions & 0 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ module Builder = struct
; cache_debug_flags : Dune_engine.Cache_debug_flags.t
; report_errors_config : Dune_engine.Report_errors_config.t
; separate_error_messages : bool
; stop_on_first_error : bool
; require_dune_project_file : bool
; insignificant_changes : [ `React | `Ignore ]
; watch_exclusions : string list
Expand Down Expand Up @@ -952,6 +953,13 @@ module Builder = struct
& info
[ "display-separate-messages" ]
~doc:"Separate error messages with a blank line.")
and+ stop_on_first_error =
Arg.(
value
& flag
& info
[ "stop-on-first-error" ]
~doc:"Stop the build as soon as an error is encountered.")
in
if Option.is_none stats_trace_file && stats_trace_extended
then User_error.raise [ Pp.text "--trace-extended can only be used with --trace" ];
Expand Down Expand Up @@ -996,6 +1004,7 @@ module Builder = struct
; cache_debug_flags
; report_errors_config
; separate_error_messages
; stop_on_first_error
; require_dune_project_file
; insignificant_changes = (if react_to_insignificant_changes then `React else `Ignore)
; watch_exclusions
Expand Down Expand Up @@ -1191,6 +1200,7 @@ let init ?action_runner ?log_file c =
Dune_engine.Clflags.diff_command := c.builder.diff_command;
Dune_engine.Clflags.promote := c.builder.promote;
Dune_engine.Clflags.force := c.builder.force;
Dune_engine.Clflags.stop_on_first_error := c.builder.stop_on_first_error;
Dune_rules.Clflags.store_orig_src_dir := c.builder.store_orig_src_dir;
Dune_rules.Clflags.promote_install_files := c.builder.promote_install_files;
Dune_engine.Clflags.always_show_command_line := c.builder.always_show_command_line;
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/8400.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add `--stop-on-first-error` option to `dune build` which will terminate the build when
the first error is encountered. (#8400, @pmwhite and @Alizter)
9 changes: 9 additions & 0 deletions test/blackbox-tests/test-cases/stop-on-first-error.t/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(rule
(target foo)
(action
(system "exit 1")))

(rule
(target bar)
(action
(system "exit 1")))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 3.10)
25 changes: 25 additions & 0 deletions test/blackbox-tests/test-cases/stop-on-first-error.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Here we demonstrate the --stop-on-first-error behaviour.

$ dune build
File "dune", line 1, characters 0-50:
1 | (rule
2 | (target foo)
3 | (action
4 | (system "exit 1")))
Command exited with code 1.
File "dune", line 6, characters 0-50:
6 | (rule
7 | (target bar)
8 | (action
9 | (system "exit 1")))
Command exited with code 1.
[1]

$ dune build --stop-on-first-error
File "dune", line 6, characters 0-50:
6 | (rule
7 | (target bar)
8 | (action
9 | (system "exit 1")))
Command exited with code 1.
[1]
0