diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 02:37:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 02:37:39 -0300 |
| commit | 6c0e9c5a6b6d4b0aa77f084fdac5eb4f6d1f482b (patch) | |
| tree | 7567624fe00948134ab5ee59f6cd081872318bce /src/ninep | |
| parent | 803f2a2678a8aa8f89b0663a84a60721d36f5831 (diff) | |
| download | pardes-6c0e9c5a6b6d4b0aa77f084fdac5eb4f6d1f482b.tar.gz pardes-6c0e9c5a6b6d4b0aa77f084fdac5eb4f6d1f482b.zip | |
A ThemeFile that fails to load changes nothing: /ctl and DumpConfig keep naming the file last loaded, or none, so they always replay
The request's path was taken as the theme file before the host had
read it, so a file not found or not ZON left /ctl saying ThemeFile
<that path>, and writing the report back failed again. The path a load
succeeds with is now kept apart; a failure puts the request back to it
(and watches it again), or to none.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index a4979f7d..e963da3f 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2034,6 +2034,32 @@ test "DumpConfig's whole report writes back to the root ctl, line by line, with } } +test "a ThemeFile that fails to load changes nothing: the root ctl still names the one loaded, or none" { + if (comptime !pardes.hosted) return; + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const root_ctl = @intFromEnum(tree.TopFile.ctl); + // None loaded: a failed one leaves Theme as it was. + _ = wr(p, root_ctl, "ThemeFile /tmp/pardes-no-such-theme.zon\n"); + pardes.colors.failThemeFile(p, p.theme_file_generation, error.FileNotFound); + try testing.expect(std.mem.indexOf(u8, rd(p, root_ctl, 0, 1 << 16).bytes, "ThemeFile") == null); + try testing.expectEqualStrings("", p.theme_file_path.get()); + // One loaded, then another that fails: still the first, on every read. + const good = "/tmp/pardes-good-theme.zon"; + _ = wr(p, root_ctl, "ThemeFile " ++ good ++ "\n"); + var custom = pardes.themes[0]; + custom.name = "good"; + var encoded: std.Io.Writer.Allocating = .init(gpa); + defer encoded.deinit(); + try std.zon.stringify.serialize(custom, .{}, &encoded.writer); + try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written(), false)); + _ = wr(p, root_ctl, "ThemeFile /tmp/pardes-bad-theme.zon\n"); + try testing.expect(!pardes.colors.loadThemeFile(p, p.theme_file_generation, ".{ .name = ", false)); + try testing.expect(std.mem.indexOf(u8, rd(p, root_ctl, 0, 1 << 16).bytes, "ThemeFile " ++ good ++ "\n") != null); + try testing.expectEqualStrings(good, p.theme_file_path.get()); +} + test "after a ThemeFile the root ctl and DumpConfig say ThemeFile and its path, which writes back" { if (comptime !pardes.hosted) return; const gpa = testing.allocator; |
