From 4c7e3d1454062a5815b8fc2bd19765e6749d5a7b Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 6 Nov 2026 21:08:42 +0000 Subject: [PATCH] Make the build system's output wording, labels and colors consistent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: The build system's messages still followed the Rust implementation's output, which the OCaml one had to match exactly (#9244). Output modified (redirected rescript build): Before (text): Cleaned 0/0 Parsed 1 source files Compiled 1 modules Incremental build failed. Error: \e[2K\r Failed to Compile. See Errors Above After (text): Cleaned 0 stale modules Parsed 1 source file Compiled 1 module Build failed: see the errors above. Diagnostic modified (labels and wording): Before (text): ERROR: Could not read folder: "nosuch". Specified in dependency: dep, located ""... WARN: Package 'dep' has not defined any sources, … Duplicated package: a ./node_modules/a (chosen) vs … in ./node_modules/b \e[2K\r No implementation file found for interface file (skipping): src/B.resi Error in pkg: DEBUG: Compiling file: A compile dirty: A TRACE: Compiled 2 out of 2 in the universe … is not supported by ReScript 12's new build system. Could not start Rescript build: … After (text): warning: source folder "nosuch" of package dep () does not exist or is not a folder warning: package 'dep' has not defined any sources, … warning: duplicated package: a ./node_modules/a (chosen) vs … in ./node_modules/b warning: no implementation file found for interface file (skipping): src/B.resi (no header before parse errors) debug: Compiling file: A trace: compile dirty: A trace: compiled 2 of the 2 modules to check … is not supported by the ReScript build system. Could not start ReScript build: … The other changes: - a redirected one-shot build ends with Finished compilation, like watch; - compiler errors and warnings are printed without colors when colors are off (redirected output, NO_COLOR); .compiler.log keeps them for editors; - config diagnostics are separated by one blank line; - rescript clean labels its second step "generated files" when no output is in-source, instead of an empty suffix list; - the cleanup step no longer counts the previous ASTs, which only the Cleaned N/M line printed. Review: Why are config diagnostics still printed after the progress lines? Moving them before would restructure the report for little gain; only their spacing changes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU Signed-off-by: Christoph Knittel --- changes/build-output-wording.polish.md | 7 ++++ rewatch-ocaml/build.ml | 14 ++----- rewatch-ocaml/build_artifacts.ml | 9 +---- rewatch-ocaml/build_artifacts.mli | 1 - rewatch-ocaml/build_attempt.ml | 2 - rewatch-ocaml/build_attempt.mli | 1 - rewatch-ocaml/build_lock.ml | 2 +- rewatch-ocaml/build_preparation.ml | 4 +- rewatch-ocaml/build_report.ml | 24 ++++++----- rewatch-ocaml/clean.ml | 4 +- rewatch-ocaml/compiler_scheduler.ml | 4 +- rewatch-ocaml/config.ml | 2 +- rewatch-ocaml/format.ml | 5 ++- rewatch-ocaml/output.ml | 40 ++++++++++++------- rewatch-ocaml/output.mli | 14 ++++--- rewatch-ocaml/package_diagnostics.ml | 9 ++--- rewatch-ocaml/package_graph.ml | 2 +- rewatch-ocaml/package_parse.ml | 4 +- rewatch-ocaml/package_resolution.ml | 3 +- .../tests/check_command_validation.sh | 12 +++--- .../tests/check_interactive_output.sh | 20 +++++----- rewatch-ocaml/tests/check_verbose_output.sh | 11 +---- rewatch-ocaml/tests/run.sh | 4 +- .../build-dependency-without-sources.txt | 3 +- .../build-missing-source-folder.txt | 3 +- .../build-source-path-is-file.txt | 3 +- .../clean-dependency-without-sources.txt | 3 +- .../forced-color-config-diagnostics.txt | 10 ++--- .../format-dependency-without-sources.txt | 3 +- .../quiet-compile-error.txt | 16 ++++---- .../command_validation/quiet-parse-error.txt | 11 +++-- .../command_validation/quiet-warning.txt | 10 ++--- .../command_validation/quiet-watch.txt | 9 ++--- .../redirected-compile-error.txt | 22 +++++----- .../redirected-config-diagnostics.txt | 10 ++--- .../redirected-parse-error.txt | 13 +++--- .../command_validation/redirected-success.txt | 3 +- .../command_validation/redirected-warning.txt | 13 +++--- .../tests/snapshots/verbose_output/v.txt | 24 +++++------ .../verbose_output/vv-incremental.txt | 14 +++---- .../tests/snapshots/verbose_output/vv.txt | 34 ++++++++-------- rewatch-ocaml/watcher.ml | 2 +- rewatch/tests/lock/01-lock-when-watching.sh | 2 +- rewatch/tests/snapshots/dependency-cycle.txt | 19 +++++---- .../dev-dependency-used-by-non-dev-source.txt | 29 +++++++------- rewatch/tests/snapshots/remove-file.txt | 35 ++++++++-------- .../rename-file-internal-dep-namespace.txt | 31 +++++++------- .../snapshots/rename-file-internal-dep.txt | 33 ++++++++------- .../snapshots/rename-file-with-interface.txt | 18 ++++----- rewatch/tests/snapshots/rename-file.txt | 16 ++++---- .../tests/snapshots/rename-interface-file.txt | 18 ++++----- .../watch/06-watch-missing-source-folder.sh | 2 +- tests/build_tests/cli_compile_status/input.js | 8 ++-- .../duplicated_symlinked_packages/input.js | 2 +- .../not_undefined_attribute/input.js | 2 +- .../unboxed_bool_with_const/input.js | 2 +- .../build_attempt_tests.ml | 6 +-- tests/rewatch_ounit_tests/output_tests.ml | 10 +++++ 58 files changed, 318 insertions(+), 319 deletions(-) create mode 100644 changes/build-output-wording.polish.md diff --git a/changes/build-output-wording.polish.md b/changes/build-output-wording.polish.md new file mode 100644 index 00000000000..e953cc1815a --- /dev/null +++ b/changes/build-output-wording.polish.md @@ -0,0 +1,7 @@ +- The build system's messages read more consistently: + - counts use the singular for one (`Parsed 1 source file`, `Compiled 1 module`), and the cleanup step reports `Cleaned N stale modules`; + - a failed build ends with `Build failed: see the errors above.`, without a terminal escape sequence when redirected; + - a redirected one-shot build ends with `Finished compilation`, like watch mode; + - warnings and verbose logs are labeled inline (`warning: …`, `debug: …`, `trace: …`), and a missing source folder is a warning; + - parse errors no longer get an `Error in :` header; + - compiler errors and warnings are uncolored when output is redirected or `NO_COLOR` is set. diff --git a/rewatch-ocaml/build.ml b/rewatch-ocaml/build.ml index eb27fb0d320..bf72d332143 100644 --- a/rewatch-ocaml/build.ml +++ b/rewatch-ocaml/build.ml @@ -292,22 +292,17 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity if attempt.freshness_mode = Build_attempt.Initialize_freshness then Source_dirs.write_build ~root_config attempt.session; Build_report.report_failure report ~compile_seconds; - prerr_string output; + prerr_string (Output.compiler_output ~color:colors output); prerr_newline (); Build_attempt.cleanup_artifacts attempt; - raise - (Reported_failure - ("Incremental build failed. Error: \027[2K\r Failed to Compile. " - ^ "See Errors Above")) + raise (Reported_failure "Build failed: see the errors above.") in let report_parse_failure output = Build_attempt.finalize_logs attempt; Build_report.report_parse_failure report ~output; Build_attempt.cleanup_artifacts attempt; raise - (Reported_failure - "Incremental build failed. Error: \027[2K\r Could not parse Source \ - Files") + (Reported_failure "Build failed: could not parse the source files above.") in let format_cycle cycle (by_key : (string, Module_graph.cycle_node) Hashtbl.t) = @@ -352,8 +347,7 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity (Output.compiler_cleanup_message ~color:colors ~step:"1/3"); print_endline (Output.cleanup_message ~color:colors ~step:"1/3" - ~cleaned:attempt.cleaned ~total:attempt.previous_asts - ~seconds:(phase_seconds seconds)))) + ~cleaned:attempt.cleaned ~seconds:(phase_seconds seconds)))) in (preparation.prepared, preparation.cycle) in diff --git a/rewatch-ocaml/build_artifacts.ml b/rewatch-ocaml/build_artifacts.ml index 6d16c3ea345..4d50c717daf 100644 --- a/rewatch-ocaml/build_artifacts.ml +++ b/rewatch-ocaml/build_artifacts.ml @@ -102,7 +102,6 @@ let generated_output_details_for_suffixes suffixes path = type cleanup_result = { removed_modules: string list; - previous_ast_count: int; present_public_outputs: (string, unit) Hashtbl.t; } @@ -209,7 +208,6 @@ let cleanup_stale ~artifact_files ~ast_sources ~present_source_files Config.namespace_compiler_name config.namespace |> Option.iter (fun namespace -> add_expected namespace [".cmi"; ".cmj"; ".cmt"; ".mlmap"]); - let previous_ast_count = ref 0 in let removed_modules = ref [] in artifact_files |> List.iter (fun path -> @@ -218,7 +216,6 @@ let cleanup_stale ~artifact_files ~ast_sources ~present_source_files Filename.check_suffix basename ".ast" || Filename.check_suffix basename ".iast" in - if is_ast then incr previous_ast_count; if Compile_assets.is_managed_basename basename && ((not (Hashtbl.mem expected_artifacts basename)) @@ -239,8 +236,4 @@ let cleanup_stale ~artifact_files ~ast_sources ~present_source_files Hashtbl.remove present_public_outputs (path ^ ".map"); File_util.remove_file path; File_util.remove_file (path ^ ".map")); - { - removed_modules = !removed_modules; - previous_ast_count = !previous_ast_count; - present_public_outputs; - } + {removed_modules = !removed_modules; present_public_outputs} diff --git a/rewatch-ocaml/build_artifacts.mli b/rewatch-ocaml/build_artifacts.mli index 72f9e94ed8a..d5b84d92725 100644 --- a/rewatch-ocaml/build_artifacts.mli +++ b/rewatch-ocaml/build_artifacts.mli @@ -1,6 +1,5 @@ type cleanup_result = { removed_modules: string list; - previous_ast_count: int; present_public_outputs: (string, unit) Hashtbl.t; } (** Artifact cleanup first classifies ownership and builds a deletion plan. diff --git a/rewatch-ocaml/build_attempt.ml b/rewatch-ocaml/build_attempt.ml index 651edd84856..e6489ce1e35 100644 --- a/rewatch-ocaml/build_attempt.ml +++ b/rewatch-ocaml/build_attempt.ml @@ -36,7 +36,6 @@ type t = { freshness_mode: freshness_mode; session: Build_session.t; mutable cleaned: int; - mutable previous_asts: int; mutable parsed: int; mutable compiled: int; mutable parse_seconds: float; @@ -64,7 +63,6 @@ let create ~freshness_mode ~session ~process_poll ~progress ~verbosity = freshness_mode; session; cleaned = 0; - previous_asts = 0; parsed = 0; compiled = 0; parse_seconds = 0.; diff --git a/rewatch-ocaml/build_attempt.mli b/rewatch-ocaml/build_attempt.mli index 4e486f25e6e..1977317af0c 100644 --- a/rewatch-ocaml/build_attempt.mli +++ b/rewatch-ocaml/build_attempt.mli @@ -25,7 +25,6 @@ type t = { freshness_mode: freshness_mode; session: Build_session.t; mutable cleaned: int; - mutable previous_asts: int; mutable parsed: int; mutable compiled: int; mutable parse_seconds: float; diff --git a/rewatch-ocaml/build_lock.ml b/rewatch-ocaml/build_lock.ml index 064907ed82e..b5444cafa22 100644 --- a/rewatch-ocaml/build_lock.ml +++ b/rewatch-ocaml/build_lock.ml @@ -11,7 +11,7 @@ let valid_owner value = let malformed_error () = Project_context.Error - "Could not start Rescript build: Could not parse lockfile PID\n\ + "Could not start ReScript build: Could not parse lockfile PID\n\ \ (try removing it and running the command again)" (* A writer that cannot link creates the lock and then writes its PID, so an diff --git a/rewatch-ocaml/build_preparation.ml b/rewatch-ocaml/build_preparation.ml index 52648703a2a..dfea4b94bc5 100644 --- a/rewatch-ocaml/build_preparation.ml +++ b/rewatch-ocaml/build_preparation.ml @@ -140,9 +140,7 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch | None -> cleanup_stale package in Build_attempt.set_cleanup_result attempt package.root cleanup; - attempt.cleaned <- attempt.cleaned + List.length cleanup.removed_modules; - attempt.previous_asts <- - attempt.previous_asts + cleanup.previous_ast_count) + attempt.cleaned <- attempt.cleaned + List.length cleanup.removed_modules) cleanups_before_clean; let compile_assets = if attempt.compiler_cleaned || Hashtbl.length attempt.removed_modules > 0 diff --git a/rewatch-ocaml/build_report.ml b/rewatch-ocaml/build_report.ml index 4f7fa04e4cd..06db97249fd 100644 --- a/rewatch-ocaml/build_report.ml +++ b/rewatch-ocaml/build_report.ml @@ -47,11 +47,14 @@ let prepare report ~success ~compile_seconds = else ( (match report.kind with | One_shot | Initial_watch | Full_watch -> - Printf.printf "Cleaned %d/%d\n%!" attempt.cleaned attempt.previous_asts + Printf.printf "Cleaned %s\n%!" + (Output.stale_modules ~cleaned:attempt.cleaned) | Incremental_watch -> ()); - Printf.printf "Parsed %d source files\n%!" attempt.parsed; - if success then Printf.printf "Compiled %d modules\n%!" attempt.compiled - else Printf.eprintf "Compiled %d modules\n%!" attempt.compiled); + Printf.printf "Parsed %s\n%!" + (Output.count_of attempt.parsed "source file"); + let compiled = Output.count_of attempt.compiled "module" in + if success then Printf.printf "Compiled %s\n%!" compiled + else Printf.eprintf "Compiled %s\n%!" compiled); let diagnostics = match report.kind with | Incremental_watch | Full_watch -> [] @@ -62,13 +65,16 @@ let prepare report ~success ~compile_seconds = Warning_state.entries (Build_session.warning_state attempt.session) in List.iter - (fun entry -> prerr_string entry.Warning_state.output) + (fun entry -> + prerr_string + (Output.compiler_output ~color:report.colors entry.Warning_state.output)) warning_entries; if warning_entries <> [] then prerr_newline (); flush stderr; if diagnostics <> [] then diagnostics |> List.map (fun diagnostic -> + let diagnostic = String.trim diagnostic in if report.colors then Output.yellow diagnostic else diagnostic) |> String.concat "\n\n" |> prerr_endline; diagnostics @@ -87,7 +93,7 @@ let report_completion report diagnostics = (Build_session.warning_state report.attempt.session) <> []) ~seconds) - else if report.kind <> One_shot && report.show_progress then + else if report.show_progress then Printf.printf "Finished %scompilation\n%!" (match report.kind with | Initial_watch -> "initial " @@ -111,7 +117,7 @@ let report_parse_failure report ~output = else if report.show_progress then match report.kind with | One_shot | Initial_watch | Full_watch -> - Printf.printf "Cleaned %d/%d\n%!" report.attempt.cleaned - report.attempt.previous_asts + Printf.printf "Cleaned %s\n%!" + (Output.stale_modules ~cleaned:report.attempt.cleaned) | Incremental_watch -> ()); - prerr_endline output + prerr_endline (Output.compiler_output ~color:report.colors output) diff --git a/rewatch-ocaml/clean.ml b/rewatch-ocaml/clean.ml index 3312c30e2f7..e3130ecf042 100644 --- a/rewatch-ocaml/clean.ml +++ b/rewatch-ocaml/clean.ml @@ -123,7 +123,9 @@ let run ~poll ~verbosity ~folder ~prod = else None) |> String.concat ", " in - let generated_files = suffixes ^ " files" in + let generated_files = + if suffixes = "" then "generated files" else suffixes ^ " files" + in let generated_started = Unix.gettimeofday () in print_cleaning ~step:"2/2" generated_files; remove_generated_outputs cleanup; diff --git a/rewatch-ocaml/compiler_scheduler.ml b/rewatch-ocaml/compiler_scheduler.ml index 3d59c78ef9a..f5cf70f6135 100644 --- a/rewatch-ocaml/compiler_scheduler.ml +++ b/rewatch-ocaml/compiler_scheduler.ml @@ -114,7 +114,7 @@ let run ~poll ~warning_state ~compile_assets ~build_state ~candidates |> List.filter candidate_requires_compile |> List.sort (fun first second -> String.compare first.key second.key) |> List.iter (fun candidate -> - Printf.printf "compile dirty: %s\n%!" candidate.key); + Output.trace ~verbosity ("compile dirty: " ^ candidate.key)); (* The scheduler only needs dirty modules and their transitive dependents. Dependencies outside that universe already have usable artifacts, while keeping every module in the subprocess graph makes small edits scale with @@ -401,7 +401,7 @@ let run ~poll ~warning_state ~compile_assets ~build_state ~candidates in Output.Progress.finish progress; Output.trace ~verbosity - (Printf.sprintf "Compiled %d out of %d in the universe" !completed_modules + (Printf.sprintf "compiled %d of the %d modules to check" !completed_modules (List.length scheduled_modules)); let failures = scheduled_modules diff --git a/rewatch-ocaml/config.ml b/rewatch-ocaml/config.ml index eb5fd35d5d7..7ae9da8df74 100644 --- a/rewatch-ocaml/config.ml +++ b/rewatch-ocaml/config.ml @@ -411,7 +411,7 @@ let load path = |> List.map (fun field -> Printf.sprintf "The field '%s' found in the package config of '%s' is not \ - supported by ReScript 12's new build system." + supported by the ReScript build system." field name)) @ (unknown_fields fields |> List.map (fun field -> diff --git a/rewatch-ocaml/format.ml b/rewatch-ocaml/format.ml index 7316e259544..58dbce54341 100644 --- a/rewatch-ocaml/format.ml +++ b/rewatch-ocaml/format.ml @@ -163,7 +163,10 @@ let format_files ?poll ~check files = prerr_endline (format_check_summary (List.length !unformatted)); List.iter (fun (path, message) -> - prerr_endline (formatting_error (display path) message)) + prerr_endline + (Output.compiler_output + ~color:(Output.colors_enabled ~interactive:(Unix.isatty Unix.stderr)) + (formatting_error (display path) message))) (List.sort compare !failures); match (!failures, !unformatted) with | [], [] -> () diff --git a/rewatch-ocaml/output.ml b/rewatch-ocaml/output.ml index b0895903b13..8261b6237e0 100644 --- a/rewatch-ocaml/output.ml +++ b/rewatch-ocaml/output.ml @@ -1,16 +1,19 @@ let line_clear = "\027[2K\r" +(* [count_of 1 "module"] is "1 module", [count_of 2 "module"] "2 modules". *) +let count_of count noun = + Printf.sprintf "%d %s%s" count noun (if count = 1 then "" else "s") + (* Logs go to stdout by default. Commands whose stdout is machine-readable output (compiler-args, format) log to stderr instead. *) let log ?(channel = stdout) ~minimum ~verbosity ~label message = - if verbosity >= minimum then - Printf.fprintf channel "%s:\n%s\n%!" label message + if verbosity >= minimum then Printf.fprintf channel "%s: %s\n%!" label message let debug ?channel ~verbosity message = - log ?channel ~minimum:1 ~verbosity ~label:"DEBUG" message + log ?channel ~minimum:1 ~verbosity ~label:"debug" message let trace ?channel ~verbosity message = - log ?channel ~minimum:2 ~verbosity ~label:"TRACE" message + log ?channel ~minimum:2 ~verbosity ~label:"trace" message let trace_enabled verbosity = verbosity >= 2 let format_step ~color step = @@ -73,7 +76,7 @@ module Progress = struct if verbosity >= 1 then ( let redraw = progress.enabled && Option.is_some progress.phase in if redraw then Printf.printf "%s%!" line_clear; - log ~minimum:1 ~verbosity ~label:"DEBUG" message; + log ~minimum:1 ~verbosity ~label:"debug" message; if redraw then draw ~force:true progress) let start_grouped progress ~step ~symbol ~label groups = @@ -157,9 +160,12 @@ let duration = function | Some seconds -> Printf.sprintf " in %.2fs" seconds | None -> "" -let cleanup_message ~color ~step ~cleaned ~total ~seconds = - Printf.sprintf "%s%s %sCleaned %d/%d%s" line_clear (format_step ~color step) - Platform.clean_symbol cleaned total (duration seconds) +(* What a build's cleanup step removed: the modules whose sources are gone. *) +let stale_modules ~cleaned = count_of cleaned "stale module" + +let cleanup_message ~color ~step ~cleaned ~seconds = + Printf.sprintf "%s%s %sCleaned %s%s" line_clear (format_step ~color step) + Platform.clean_symbol (stale_modules ~cleaned) (duration seconds) let compiler_cleanup_message ~color ~step = Printf.sprintf "%s%s %sCleaned previous build due to compiler update" @@ -174,20 +180,22 @@ let cleaned_command_message ~color ~step ~target ~seconds = Platform.clean_symbol target (duration seconds) let parsing_message ~color ~step ~count ~seconds = - Printf.sprintf "%s%s %sParsed %d source files%s" line_clear - (format_step ~color step) Platform.parse_symbol count (duration seconds) + Printf.sprintf "%s%s %sParsed %s%s" line_clear (format_step ~color step) + Platform.parse_symbol + (count_of count "source file") + (duration seconds) let parsing_failed_message ~color ~step ~seconds = Printf.sprintf "%s%s %sError parsing source files%s" line_clear (format_step ~color step) Platform.error_symbol (duration seconds) let compiling_message ~color ~step ~count ~seconds = - Printf.sprintf "%s%s %sCompiled %d modules%s" line_clear - (format_step ~color step) Platform.build_symbol count (duration seconds) + Printf.sprintf "%s%s %sCompiled %s%s" line_clear (format_step ~color step) + Platform.build_symbol (count_of count "module") (duration seconds) let compilation_failed_message ~color ~step ~count ~seconds = - Printf.sprintf "%s%s %sCompiled %d modules%s" line_clear - (format_step ~color step) Platform.error_symbol count (duration seconds) + Printf.sprintf "%s%s %sCompiled %s%s" line_clear (format_step ~color step) + Platform.error_symbol (count_of count "module") (duration seconds) type compilation_label = Standard | Initial | Incremental @@ -207,3 +215,7 @@ let finished_compilation_message ~label ~warnings ~seconds = let should_clear_screen ~clear_screen ~show_progress ~interactive = clear_screen && show_progress && interactive + +(* The compiler always colors its diagnostics, which stay colored in + .compiler.log for editors; printed, they follow the color policy. *) +let compiler_output ~color text = if color then text else strip_sgr text diff --git a/rewatch-ocaml/output.mli b/rewatch-ocaml/output.mli index 1d6d277c598..890a5619aed 100644 --- a/rewatch-ocaml/output.mli +++ b/rewatch-ocaml/output.mli @@ -26,14 +26,16 @@ val colors_enabled_with : val colors_enabled : interactive:bool -> bool val strip_sgr : string -> string +val compiler_output : color:bool -> string -> string + +val count_of : int -> string -> string +(** [count_of 1 "module"] is ["1 module"], [count_of 2 "module"] + ["2 modules"]. *) + +val stale_modules : cleaned:int -> string val cleanup_message : - color:bool -> - step:string -> - cleaned:int -> - total:int -> - seconds:float option -> - string + color:bool -> step:string -> cleaned:int -> seconds:float option -> string val compiler_cleanup_message : color:bool -> step:string -> string val cleaning_command_message : color:bool -> step:string -> string -> string diff --git a/rewatch-ocaml/package_diagnostics.ml b/rewatch-ocaml/package_diagnostics.ml index ffb71567d47..17f31876e7f 100644 --- a/rewatch-ocaml/package_diagnostics.ml +++ b/rewatch-ocaml/package_diagnostics.ml @@ -85,17 +85,16 @@ let report_missing_source_folder (config : Config.t) path = else path in Printf.eprintf - "ERROR:\n\ - Could not read folder: %S. Specified in dependency: %s, located %S...\n\ + "warning: source folder %S of package %s (%s) does not exist or is not a \ + folder\n\ %!" relative config.name config.root let report_missing_sources ~is_root (config : Config.t) = if (not is_root) && not config.sources_defined then Printf.eprintf - "WARN:\n\ - Package '%s' has not defined any sources, but is not the root package. \ - This is likely a mistake. It is located: %s\n\ + "warning: package '%s' has not defined any sources, but is not the root \ + package. This is likely a mistake. It is located: %s\n\ %!" config.name config.root diff --git a/rewatch-ocaml/package_graph.ml b/rewatch-ocaml/package_graph.ml index 4a402e3f364..cd995e8905b 100644 --- a/rewatch-ocaml/package_graph.ml +++ b/rewatch-ocaml/package_graph.ml @@ -108,7 +108,7 @@ let discover ~(root_config : Config.t) ~(workspace_config : Config.t) ~prod ~on_missing:(Package_diagnostics.report_missing_source_folder config) ~on_orphan:(fun path -> Printf.eprintf - "\027[2K\r No implementation file found for interface file \ + "warning: no implementation file found for interface file \ (skipping): %s\n\ %!" path) diff --git a/rewatch-ocaml/package_parse.ml b/rewatch-ocaml/package_parse.ml index f2e002ac33c..b068dbf1ed5 100644 --- a/rewatch-ocaml/package_parse.ml +++ b/rewatch-ocaml/package_parse.ml @@ -91,9 +91,7 @@ let run ~(package : Package_plan.t) ~(prepared : Build_session.prepared) match result with | Build_attempt.Parse_failed {stdout; stderr} -> Build_session.mark_parse_pending attempt.session pending_path; - let output = - Printf.sprintf "Error in %s:\n%s%s" config.name stderr stdout - in + let output = stderr ^ stdout in Compiler_log.append root output; attempt.parse_messages <- Build_attempt.Parse_error output :: attempt.parse_messages diff --git a/rewatch-ocaml/package_resolution.ml b/rewatch-ocaml/package_resolution.ml index d61a0d9c957..7ac38611bd7 100644 --- a/rewatch-ocaml/package_resolution.ml +++ b/rewatch-ocaml/package_resolution.ml @@ -73,7 +73,8 @@ let resolve resolution ~package_root (declaration : Config.dependency) = && not (Hashtbl.mem resolution.reported_duplicates key) then ( Hashtbl.add resolution.reported_duplicates key (); - Printf.eprintf "Duplicated package: %s %s (chosen) vs %s in %s\n%!" + Printf.eprintf + "warning: duplicated package: %s %s (chosen) vs %s in %s\n%!" declaration.name (Project_context.display_path ~root:resolution.root_config.root selected.directory) diff --git a/rewatch-ocaml/tests/check_command_validation.sh b/rewatch-ocaml/tests/check_command_validation.sh index 1ec819d756e..bb5d9d1d8be 100755 --- a/rewatch-ocaml/tests/check_command_validation.sh +++ b/rewatch-ocaml/tests/check_command_validation.sh @@ -500,7 +500,7 @@ run_multiple_parse_errors_case() { exit 1 fi error="$work/rescript.err" - if [ "$(grep -cF 'Error in multiple-parse-errors:' "$error")" -ne 2 ] || \ + if [ "$(grep -cF 'Syntax error!' "$error")" -ne 2 ] || \ ! grep -E '[/\\]src[/\\]A\.res' "$error" >/dev/null || \ ! grep -E '[/\\]src[/\\]B\.res' "$error" >/dev/null; then echo "rescript did not retain every independent parse error" >&2 @@ -942,7 +942,7 @@ if ! grep -Fx 'root dependencies: a' "$work/rescript.err.plain" >/dev/null || \ exit 1 fi run_case build-source-path-is-file accept build "$work/source-path-file" -if ! grep -F 'Could not read folder: "src"' "$work/rescript.err" >/dev/null; then +if ! grep -F 'warning: source folder "src" of package source-path-file' "$work/rescript.err" >/dev/null; then echo "Non-directory source diagnostic is missing" >&2 dump_output exit 1 @@ -963,7 +963,7 @@ run_case --cwd "$work/format-source-selection" \ format-scans-graph-with-effective-features reject format --check normalize_project_path "$work/rescript.err" "$work/rescript.err.norm" \ "$work/format-source-selection" -missing_folder='Could not read folder: "missing". Specified in dependency: installed' +missing_folder='warning: source folder "missing" of package installed' base_file='[format check] packages/local/base/Base.res' native_file='[format check] packages/local/native/Native.res' other_file='/packages/local/other/Other.res' @@ -1028,7 +1028,7 @@ run_case build-malformed-dependency reject build "$work/malformed-dependency" require_error_contains build-malformed-dependency \ "Could not build package tree for 'bad-config' at path '$work/malformed-dependency'. Error:" run_case build-duplicate-dependency accept build "$work/duplicate-dependency" -duplicate_warning='Duplicated package: shared ./node_modules/shared (chosen) vs ./node_modules/a/node_modules/shared in ./node_modules/a' +duplicate_warning='warning: duplicated package: shared ./node_modules/shared (chosen) vs ./node_modules/a/node_modules/shared in ./node_modules/a' normalize_project_path "$work/rescript.err" "$work/rescript.err.norm" \ "$work/duplicate-dependency" if ! grep -F "$duplicate_warning" "$work/rescript.err.norm" >/dev/null; then @@ -1277,7 +1277,7 @@ rm "$quiet_watch_project/lib/rescript/watch.lock" wait_for_exit "$quiet_watch_pid" wait "$quiet_watch_pid" if [ -s "$work/quiet-watch.out" ] || \ - grep -F "Incremental build failed" "$work/quiet-watch.err" >/dev/null; then + grep -F "Build failed" "$work/quiet-watch.err" >/dev/null; then echo "quiet-watch: quiet watch emitted progress or a duplicate failure summary" >&2 cat "$work/quiet-watch.out" "$work/quiet-watch.err" >&2 exit 1 @@ -1286,7 +1286,7 @@ fi # rebuild reports the parse error again. Compare the distinct reports only. node -e ' const fs = require("fs"); - const blocks = fs.readFileSync(process.argv[1], "utf8").split(/^(?=Error in )/m); + const blocks = fs.readFileSync(process.argv[1], "utf8").split(/^(?= Syntax error!)/m); const distinct = blocks.filter((block, i) => block !== blocks[i - 1]); fs.writeFileSync(process.argv[2], distinct.join("")); ' "$work/quiet-watch.err" "$work/quiet-watch.err.distinct" diff --git a/rewatch-ocaml/tests/check_interactive_output.sh b/rewatch-ocaml/tests/check_interactive_output.sh index c196349d677..0b9ccf6e387 100755 --- a/rewatch-ocaml/tests/check_interactive_output.sh +++ b/rewatch-ocaml/tests/check_interactive_output.sh @@ -136,9 +136,9 @@ if ! grep -E '^\[2/3\] 🧱 Parsing\.\.\. .+ [0-9]+/1' \ fi cat >"$work/expected" <<'EOF' -[1/3] 🧹 Cleaned 0/0 -[2/3] 🧱 Parsed 1 source files -[3/3] 🤺 Compiled 1 modules +[1/3] 🧹 Cleaned 0 stale modules +[2/3] 🧱 Parsed 1 source file +[3/3] 🤺 Compiled 1 module ✅ Finished compilation EOF @@ -336,9 +336,9 @@ echo "Checking interactive watch rebuilds..." capture_watch_rebuild cat >"$work/expected-watch-initial" <<'EOF' -[1/3] 🧹 Cleaned 0/0 in