diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 19:43:00 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 19:43:00 -0300 |
| commit | 87822a49e691c31566f257765dbcae5eeffc89dc (patch) | |
| tree | d1133330f322b148baf6a2c6bbb589df0482467b | |
| parent | 06c9201b3bea985a8d9658a9a95f09b11cb00535 (diff) | |
| download | pardes-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
| -rw-r--r-- | core/Messages.zig | 35 | ||||
| -rw-r--r-- | core/panes.zig | 27 |
2 files changed, 59 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" })); diff --git a/core/panes.zig b/core/panes.zig index f4f528b7..67cee035 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -2023,6 +2023,33 @@ test "a command whose run fails naming places is an error of its pane, those pla try std.testing.expect(p.messages.headline() == null or p.messages.headline().?.kind != .@"error"); } +test "a failed run's places are read against the directory its tool says it is in: make's `Entering directory` (make -C, a make in a make) until its `Leaving directory`, as Emacs's compilation mode and Vim's %D and %X read them, those two lines no detail" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane's terminal + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{}); + defer p.deinit(); + while (p.nextEffect()) |_| {} + p.setCwd(.at(0), "/tmp/pardes-cmd/src/torque"); + _ = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pardes-cmd/src/torque/pic.ppm", null); + const dst = exec.execute(p, 1, "make -C ../..") orelse return error.NoCommandPane; + while (p.nextEffect()) |_| {} + p.update(.{ .output = .{ .pane = .at(dst), .bytes = "make: Entering directory '/tmp/pardes-cmd'\r\n" ++ + "src/torque/types.cc:163:53: error: did you mean to use '->'?\r\n" ++ + "make[1]: Entering directory '/tmp/pardes-cmd/tools'\r\n" ++ + "check.cc:3:1: warning: unused variable 'b'\r\n" ++ + "make[1]: Leaving directory '/tmp/pardes-cmd/tools'\r\n" ++ + "utils.cc:7:2: note: declared here\r\n" ++ + "make: Leaving directory '/tmp/pardes-cmd'\r\n" ++ + "types.h:1:1: note: in the run's own directory again\r\n" } }); + p.update(.{ .exited = .{ .pane = .at(dst), .status = 2 } }); + const said = p.messages.headline() orelse return error.NothingSaid; + var names: [512]u8 = undefined; + var w: std.Io.Writer = .fixed(&names); + for (said.places[0..said.places_len]) |*place| try w.print("{s}:{d}:{d} ", .{ place.path.slice(), place.line, place.col }); + try std.testing.expectEqualStrings("/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 ", w.buffered()); + try std.testing.expectEqual(@as(u8, 0), said.detail_len); +} + test "a failed run's error names that run's places, each once: a rerun in the same pane does not read the run before it again, and a note at an error's place is not a second place" { if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane's terminal const gpa = std.testing.allocator; |
