summaryrefslogtreecommitdiff
path: root/core/Messages.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 19:43:00 -0300
committerGabriel Schneider <[email protected]>2026-11-26 19:43:00 -0300
commit87822a49e691c31566f257765dbcae5eeffc89dc (patch)
treed1133330f322b148baf6a2c6bbb589df0482467b /core/Messages.zig
parent06c9201b3bea985a8d9658a9a95f09b11cb00535 (diff)
downloadpardes-87822a49e691c31566f257765dbcae5eeffc89dc.tar.gz
pardes-87822a49e691c31566f257765dbcae5eeffc89dc.zip
Messages.readPlaces: a failed run's places are read against the directory its tool says it is in, as Emacs's compilation mode and Vim's errorformat (%D, %X) read them: after a make's `Entering directory 'X'` X's, until its `Leaving directory` (a make -C, a make in a make), after ninja's relative `Entering directory `out/x64'` the run's directory's out/x64; those lines are no detail (VIDEO2's B7, agent V5: `:make -C ../..` from V8's src/torque failed naming `src/torque/types.cc:163:53`, read as /tmp/v8/src/torque/src/torque/types.cc, so SPC e could not go there); THE CAUSE: readPlaces joined every relative path to the run's own directory (Pane.commandDone passes pane.cwdSlice()), and make's `make: Entering directory '/tmp/v8'` (and its Leaving) went by as rows; THE FIX: readPlaces keeps the directories entered, innermost last, in a fixed [8] (past it the depth still counts, so each Leaving leaves its own), and joins a relative place to the innermost (to the run's directory and it when that one is relative); no other reader of places, no dump, digest, frame or hot path touched (a failed run's last 400 rows, once at its exit); NOT COVERED: a Look on the same `path:line:col` words in the command pane's body still reads them against the pane's directory (look.zig), and a report row longer than the pane is wrapped by the terminal, its continuation read as a row (the long clang line of this change's first test gave its tail as detail: the test's line is shortened); RUN (TEST FIRST): panes.zig "a failed run's places are read against the directory its tool says it is in ..." runs `make -C ../..` from /tmp/pardes-cmd/src/torque and feeds the pane make's report: Entering /tmp/pardes-cmd, an error at src/torque/types.cc:163:53, make[1] Entering tools/ with a warning at check.cc:3:1, its Leaving, a note at utils.cc:7:2, make's Leaving, a note at types.h:1:1; it asks the four places /tmp/pardes-cmd/src/torque/types.cc:163:53, /tmp/pardes-cmd/tools/check.cc:3:1, /tmp/pardes-cmd/utils.cc:7:2, /tmp/pardes-cmd/src/torque/types.h:1:1 and no detail: fails on mnywmkpn 06c9201b3bea (the four read as /tmp/pardes-cmd/src/torque/src/torque/types.cc, .../src/torque/check.cc, .../src/torque/utils.cc, .../src/torque/types.h), passes now; Messages.zig's readPlaces test gains ninja's relative directory (`/src/v8/out/x64/../../src/api.cc`); a user hit it with every make -C or recursive make whose report names a relative path (and ninja -C, V8's own build); the real check (make 4.4 and clang++ on .scratch/walkui/CA/demo, this tree's Debug tui in a private session): see CA's report; GATES (Debug tui): shell-test -Dtest-filter=directory 79/79, core-test 1172/1348 (176 skipped: the new test needs a terminal, +1); load 1.5 to 7.5
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Messages.zig')
-rw-r--r--core/Messages.zig35
1 files changed, 32 insertions, 3 deletions
diff --git a/core/Messages.zig b/core/Messages.zig
index 35eb7f51..9b5b4265 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -440,15 +440,34 @@ pub fn inkOn(inks: anytype, kind: Kind) [3]u8 {
}
/// The places a compiler's report names put on `s`: each
-/// `path:line:col: error|warning|note: words` row (a relative path is
-/// `dir`'s), its words there, each place once, and the rows after the
+/// `path:line:col: error|warning|note: words` row (a relative path read
+/// against the directory the tool says it is in, as Emacs's compilation
+/// mode and Vim's %D and %X read it: a make's `Entering directory 'X'`
+/// until its `Leaving directory`, ninja's relative to `dir`; else `dir`,
+/// the run's), its words there, each place once, and the rows after the
/// first error, up to the next place, its detail. How many it found; none
/// without an error.
pub fn readPlaces(s: *Said, dir: []const u8, rows: []const []const u8) usize {
var errors: usize = 0;
var detailing = false;
+ // The directories entered, the innermost last; past its room the
+ // depth still counts, so each `Leaving` leaves its own.
+ var entered: [8][]const u8 = undefined;
+ var depth: usize = 0;
for (rows) |raw| {
const row = std.mem.trimEnd(u8, raw, " \t\r\n");
+ if (std.mem.indexOf(u8, row, ": Entering directory ")) |from| {
+ // Quoted `'X'`, or `` `X' `` by an older make and ninja.
+ const quoted = row[from + ": Entering directory ".len ..];
+ if (quoted.len < 3) continue;
+ if (depth < entered.len) entered[depth] = quoted[1 .. quoted.len - 1];
+ depth += 1;
+ continue;
+ }
+ if (std.mem.indexOf(u8, row, ": Leaving directory ") != null) {
+ depth -|= 1;
+ continue;
+ }
const found = placeOf(row) orelse {
if (detailing and row.len > 0 and s.detail_len < Said.max_detail) {
s.detail[s.detail_len] = .{};
@@ -466,7 +485,13 @@ pub fn readPlaces(s: *Said, dir: []const u8, rows: []const []const u8) usize {
if (s.places_len == Said.max_places) continue;
const place = &s.places[s.places_len];
place.* = .{ .line = found.line, .col = found.col };
- if (std.Io.Dir.path.isAbsolute(found.path)) place.path.set(found.path) else _ = place.path.print("{s}/{s}", .{ std.mem.trimEnd(u8, dir, "/"), found.path });
+ const in = if (depth > 0) entered[@min(depth, entered.len) - 1] else dir;
+ if (std.Io.Dir.path.isAbsolute(found.path))
+ place.path.set(found.path)
+ else if (std.Io.Dir.path.isAbsolute(in))
+ _ = place.path.print("{s}/{s}", .{ std.mem.trimEnd(u8, in, "/"), found.path })
+ else
+ _ = place.path.print("{s}/{s}/{s}", .{ std.mem.trimEnd(u8, dir, "/"), std.mem.trimEnd(u8, in, "/"), found.path });
// A place named again (a note at its error's) is not a second one.
const named = for (s.places[0..s.places_len]) |*was| {
if (was.line == place.line and was.col == place.col and std.mem.eql(u8, was.path.slice(), place.path.slice())) break true;
@@ -1504,6 +1529,10 @@ test "a compiler's report names its places: each place's words, the first error'
try std.testing.expectEqual(@as(u8, 2), s.detail_len);
try std.testing.expectEqualStrings(" const best = rank(q, name, 3) orelse continue;", s.detail[0].slice());
try std.testing.expectEqualStrings(" ^~~~", s.detail[1].slice());
+ // ninja's directory, relative to the run's.
+ var ninja: Said = .{};
+ try std.testing.expectEqual(@as(usize, 1), readPlaces(&ninja, "/src/v8", &.{ "ninja: Entering directory `out/x64'", "../../src/api.cc:4:2: error: boom" }));
+ try std.testing.expectEqualStrings("/src/v8/out/x64/../../src/api.cc", ninja.places[0].path.slice());
// No error among them: no places.
var none: Said = .{};
try std.testing.expectEqual(@as(usize, 0), readPlaces(&none, "/", &.{ "x.zig:1:1: note: only a note", "grep: nothing" }));