summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 00:02:06 -0300
committerGabriel Schneider <[email protected]>2026-11-06 01:21:34 -0300
commita6f294ef5b50aeb5b69e486838378654e318ed04 (patch)
tree3a223f1027389dd30d8347462cee4f9b6eb7ecf6 /build.zig
parente9b4f0e1c37c5c1f369d152d0a70b672433c94b5 (diff)
downloadpardes-a6f294ef5b50aeb5b69e486838378654e318ed04.tar.gz
pardes-a6f294ef5b50aeb5b69e486838378654e318ed04.zip
kinds #4, the fake addon and the addon test: addons/fake/fake.c is the template, every function of src/kinds/pardes_addon.h in a few lines (a counter its keys, clicks, words, ticks and jobs move, a 2x2 picture, a body, an address, a ctl read, a dump and a load), built by the build with -Wall -Wextra -Werror four more ways for the loader to refuse (another ABI, no pardes_addon, a word that is the core's) or reload (no record of its own); `pardes --addon-test <lib> <script>` loads a library into a session of its own (80x24 unless `size`, `seed N` for the panes' seeds, jobs at once, a clock moved only by `tick` and `settle`, which ticks until the kind asks for no frame) and prints the pane's tag, cells and placements after each line of keys, clicks and words; the addon-test step (and behaviour-test) runs it over the fake against addons/fake/fake.out; T1 (test/behaviour/addons.zig): Addon load, /addons with its path, BLAKE3 and panes open, the words in /commands and Help, a word refused away from its kind, unload refused while a pane is open, a compiled-in kind not unloadable; a library of another ABI, one with no export, one whose word is the core's and a file that is no library each refused and listed with why; a pane of the kind taking keys, a click, a word, a job, its body and ctl read, Esc leaving it; a dump restored with the addon, without it (the placeholder, a word refused there), and the addon loaded again reopening it in place with its count; a reload refused for a half-built library with the old one running on, one taking the state across by dump and load, one with no record coming back from its words' last values; a Look by an addon's extension; a test session lets go of its addons at its end (the registry is the process's); gates on the head: core-test 961/961 and unit-test 1494/1495 tui, 1538/1539 gui, behaviour-test 250/250, pane-test 171/172, snap all 108 ok, process-test 0 of 37 failed on both, addon-test ok, hxdiff 19 and hxparity 6 mismatches (the base's), hxgolf 0, replicas, gui-golden, monkey-gui, daemon.py main and window-clients, soak local pass
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 7b1967c2..30cb80d8 100644
--- a/build.zig
+++ b/build.zig
@@ -1528,6 +1528,24 @@ pub fn build(b: *std.Build) void {
.link_libc = true,
}),
}).getEmittedBin());
+ var fake_addon_lib: ?*std.Build.Step.Compile = null;
+ // The fake addon (addons/fake/fake.c) and three copies of it built
+ // wrong, which the loader must refuse (test/behaviour/addons.zig).
+ for ([_]struct { []const u8, []const u8 }{
+ .{ "fake_addon", "-DFAKE_PLAIN" },
+ .{ "fake_addon_abi", "-DFAKE_ABI=0x20000" },
+ .{ "fake_addon_no_export", "-DFAKE_NO_EXPORT" },
+ .{ "fake_addon_core_word", "-DFAKE_WORD=\"Save\"" },
+ .{ "fake_addon_no_dump", "-DFAKE_NO_DUMP" },
+ }) |variant| {
+ const lib = b.addLibrary(.{ .name = variant[0], .linkage = .dynamic, .root_module = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true }) });
+ lib.root_module.addIncludePath(b.path("src/kinds"));
+ const name_flag = if (std.mem.eql(u8, variant[0], "fake_addon_abi")) "-DFAKE_NAME=\"fakeabi\"" else if (std.mem.eql(u8, variant[0], "fake_addon_core_word")) "-DFAKE_NAME=\"fakeword\"" else "-DFAKE_PLAIN";
+ // The header is the whole contract: it compiles clean under every warning.
+ lib.root_module.addCSourceFile(.{ .file = b.path("addons/fake/fake.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror", "-Wno-override-init", variant[1], name_flag } });
+ session_options.addOptionPath(variant[0], lib.getEmittedBin());
+ if (std.mem.eql(u8, variant[0], "fake_addon")) fake_addon_lib = lib;
+ }
session_module.addOptions("session_options", session_options);
const behaviour_module = b.createModule(.{
.target = target,
@@ -1542,6 +1560,19 @@ pub fn build(b: *std.Build) void {
const behaviour_tests = b.addTest(.{ .root_module = behaviour_module, .filters = test_filters });
const behaviour_test_step = b.step("behaviour-test", "run the behavioural tests, through the 9P tree alone (test/behaviour/)");
_ = units.add(b, behaviour_tests, behaviour_test_step);
+ // An addon's own test, the template's: `--addon-test` over the fake
+ // and its script, compared with what it printed when written.
+ if (fake_addon_lib) |fake_lib| {
+ const run_addon_test = b.addRunArtifact(exe);
+ run_addon_test.addArg("--addon-test");
+ run_addon_test.addArtifactArg(fake_lib);
+ run_addon_test.addFileArg(b.path("addons/fake/fake.script"));
+ const compare = b.addSystemCommand(&.{ "diff", "-u" });
+ compare.addFileArg(b.path("addons/fake/fake.out"));
+ compare.addFileArg(run_addon_test.captureStdOut(.{}));
+ behaviour_test_step.dependOn(&compare.step);
+ b.step("addon-test", "pardes --addon-test over the fake addon, against addons/fake/fake.out").dependOn(&compare.step);
+ }
// The 9P monkey at T1 (test/monkey9p.zig): random requests against
// an in-process session, the documented rules checked after each.
// Its fixed-seed smoke run is part of behaviour-test.