Skip to content

Commit 2325c4a

Browse files
authored
Fix rewatch swallowing parse warnings (%todo) (#8135)
* Fix rewatch swallowing parse warnings (%todo) * Add test * CHANGELOG
1 parent 4d973c8 commit 2325c4a

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
#### :rocket: New Feature
2020

2121
- Add support for Set, Map, WeakSet and WeakMap to `@unboxed`. https://github.com/rescript-lang/rescript/pull/8009
22-
2322
- Reanalyze: add reactive incremental analysis (`-reactive`, `-runs`, `-churn`) and Mermaid pipeline dumping (`-mermaid`). https://github.com/rescript-lang/rescript/pull/8092
2423

2524
#### :bug: Bug fix
2625

26+
- Fix rewatch swallowing parse warnings (%todo). https://github.com/rescript-lang/rescript/pull/8135
27+
2728
#### :memo: Documentation
2829

2930
#### :nail_care: Polish

rewatch/src/build.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,10 @@ pub fn incremental_build(
261261
let result_asts = parse::generate_asts(build_state, || pb.inc(1));
262262
let timing_ast_elapsed = timing_ast.elapsed();
263263

264-
match result_asts {
265-
Ok(_ast) => {
264+
let parse_warnings = match result_asts {
265+
Ok(warnings) => {
266266
pb.finish();
267+
warnings
267268
}
268269
Err(err) => {
269270
logs::finalize(&build_state.packages);
@@ -285,7 +286,7 @@ pub fn incremental_build(
285286
plain_output,
286287
});
287288
}
288-
}
289+
};
289290
let deleted_modules = build_state.deleted_modules.clone();
290291
deps::get_deps(build_state, &deleted_modules);
291292
let timing_parse_total = timing_parse_start.elapsed();
@@ -304,6 +305,9 @@ pub fn incremental_build(
304305
);
305306
}
306307
}
308+
if helpers::contains_ascii_characters(&parse_warnings) {
309+
println!("{}", &parse_warnings);
310+
}
307311

308312
mark_modules_with_expired_deps_dirty(build_state);
309313
mark_modules_with_deleted_deps_dirty(&mut build_state.build_state);
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as assert from "node:assert";
22
import { setup } from "#dev/process";
33

4-
const { execBuildLegacy, execCleanLegacy } = setup(import.meta.dirname);
4+
const { execBuild, execClean } = setup(import.meta.dirname);
55

6-
const o1 = await execBuildLegacy();
6+
const o1 = await execBuild();
77

8-
const first_message = o1.stdout
8+
// biome-ignore lint/suspicious/noControlCharactersInRegex: strip ANSI color codes from output
9+
const stripAnsi = s => s.replace(/\x1b\[[0-9;]*m/g, "");
10+
11+
const first_message = stripAnsi(o1.stdout)
912
.split("\n")
1013
.map(s => s.trim())
1114
.find(s => s === "Warning number 110");
@@ -14,10 +17,10 @@ if (!first_message) {
1417
assert.fail(o1.stdout);
1518
}
1619

17-
// Second build using -warn-error +110
18-
const o2 = await execBuildLegacy(["-warn-error", "+110"]);
20+
// Second build using --warn-error +110
21+
const o2 = await execBuild(["--warn-error", "+110"]);
1922

20-
const second_message = o2.stdout
23+
const second_message = stripAnsi(o2.stdout)
2124
.split("\n")
2225
.map(s => s.trim())
2326
.find(s => s === "Warning number 110 (configured as error)");
@@ -26,17 +29,17 @@ if (!second_message) {
2629
assert.fail(o2.stdout);
2730
}
2831

29-
// Third build, without -warn-error +110
32+
// Third build, without --warn-error +110
3033
// The result should not be a warning as error
31-
const o3 = await execBuildLegacy();
34+
const o3 = await execBuild();
3235

33-
const third_message = o3.stdout
36+
const third_message = stripAnsi(o3.stdout)
3437
.split("\n")
3538
.map(s => s.trim())
36-
.find(s => s === "Dependency Finished");
39+
.find(s => s === "Warning number 110 (configured as error)");
3740

38-
if (!third_message) {
41+
if (o3.status !== 0 || third_message) {
3942
assert.fail(o3.stdout);
4043
}
4144

42-
await execCleanLegacy();
45+
await execClean();

0 commit comments

Comments
 (0)