summaryrefslogtreecommitdiff
path: root/build/tests.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 13:35:31 -0300
committerGabriel Schneider <[email protected]>2026-11-17 13:45:32 -0300
commit7a1c66f1a15911763db42d890e9e8172fe404170 (patch)
tree2604fc13399b96b091af1350bc6b78d6e0a9f89a /build/tests.zig
parente5c57a863004914136c4e6b0fa13ed805b3b383d (diff)
downloadpardes-7a1c66f1a15911763db42d890e9e8172fe404170.tar.gz
pardes-7a1c66f1a15911763db42d890e9e8172fe404170.zip
build: the core named once (core.module), the window's pieces made once
build/core.zig's module() makes every core: the shell, the core, the core without the terminal (core-test), pardes-isolate, the static, the bare build's window, the syntax module's (syntax-test) and the 9P test roots; each import and library a core takes is written there once, in the order the fold over core_mods and wireCore gave them, so every compile keeps its inputs. Parts holds what a core is made of, Core the few ways the products differ. Tracy's client and BSD libutil stay where they were (Tracy: the shell and the core; libutil: the shell), now said by a field. Gone: the core_mods fold and its buffers, wireCore and its eleven optional fields, the 9P roots' copies of core_module's import table and link objects. The editor library's and pardes-syntax's import lists are written out in full (editorModule, library.zig); TreeSitter.wire adds the grammars; ShellConfig has defaults, so the library's two literals are one. build/gui.zig's make() builds SDL, gui_c, sketchbook's renderer, HarfBuzz and the renderer's and atlas's tests once, and Window.wire links them into each window shell. One pardes-lspmock (tests and process-test shared it twice from one root); tools.program() makes the eleven uniform runner programs in a line each. The pdf benches (tools.pdfBenches) are made once the core is. Gates: zig build -l and -h byte-identical to the base over the matrix (bare, tui, gui, macos, ReleaseFast, -Dpdf=false, -Dtree-sitter=minimal, musl, -Dtracy), test/lib's configuration byte-identical. Warm rebuild of install addons and core-test shell-test unit-test process-test on the base's cache: tui every compile cached (0 rebuilt), 2339/2486 tests passed with the base's 4 known failures, the same counts as the base; gui one change: SDL3 had -DSDL_DISABLE_STB=1 added once per window shell (twice with -Dplatform=gui), now once, so libSDL3.a's cache path moves and pardes-gui and the shell-test root relink (their argv differ in that one path, nothing else); tests 2398/2545, as the base. Installed bin/pardes, image.so and pdf.so cmp-identical on tui; image.so and pdf.so identical on gui, pardes-gui differs by the relinked SDL3 (size 398,737,210 -> 398,733,114). zig build syntax-test, which did not compile on main, now compiles and passes (40/40). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build/tests.zig')
-rw-r--r--build/tests.zig65
1 files changed, 25 insertions, 40 deletions
diff --git a/build/tests.zig b/build/tests.zig
index 9d4399f8..efb3515f 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -1,5 +1,8 @@
const std = @import("std");
const Platform = @import("../build.zig").Platform;
+const core = @import("core.zig");
+const tools = @import("tools.zig");
+const program = tools.program;
/// unit-test and the test roots it runs, each with its own step where it
/// has one: core-test, shell-test, term-test, pane-test, behaviour-test,
@@ -8,29 +11,27 @@ pub fn add(b: *std.Build, c: struct {
addon_mod: *std.Build.Module,
atlas_test: ?*std.Build.Step.Compile,
cells_test: ?*std.Build.Step.Compile,
- cloud9: *std.Build.Module,
core_lean: *std.Build.Module,
core_module: *std.Build.Module,
+ /// core_module's configuration, for the test roots that run on its imports.
+ core_cfg: core.Core,
exe: *std.Build.Step.Compile,
- fs_bench_test: *std.Build.Step.Compile,
ghostty_vt_for_tests: ?*std.Build.Module,
image_addon: *std.Build.Step.Compile,
- image_mod: *std.Build.Module,
- lib_test_step: *std.Build.Step,
+ /// The scripted language server the sessions' language words ask.
+ lspmock: *std.Build.Step.Compile,
mupdf_check: *std.Build.Step,
optimize: std.lang.Optimize,
+ parts: core.Parts,
pdf_addon: ?*std.Build.Step.Compile,
- perf_gate_step: *std.Build.Step,
- perf_tests: *std.Build.Step.Compile,
- plain_mod: *std.Build.Module,
platform: Platform,
root_mod: *std.Build.Module,
snake_shader_lib: ?*std.Build.Step.Compile,
target: std.Build.ResolvedTarget,
- term_mod: *std.Build.Module,
test_build: *std.Build.Step,
test_filters: []const []const u8,
test_nonce: ?*std.Build.Module,
+ tools: tools.Tools,
unit_profile: *std.Build.Step.Compile,
}) void {
const unit_step = b.step("unit-test", "run native shell and module unit tests");
@@ -55,12 +56,12 @@ pub fn add(b: *std.Build, c: struct {
}
// The perf gate runs with every unit-test (a regression like a
// contrast search per grapheme costs 100x, far past the gate).
- unit_step.dependOn(c.perf_gate_step);
- unit_step.dependOn(c.lib_test_step);
+ unit_step.dependOn(c.tools.perf_gate_step);
+ unit_step.dependOn(c.tools.lib_test_step);
const units: Units = .{ .nonce = c.test_nonce, .build = c.test_build, .unit = unit_step, .match = testMatch(b, c.unit_profile, c.test_filters, unit_step), .profiler = c.unit_profile, .filters = c.test_filters };
// The perf and fs bench programs' own tests: they compile no editor.
- _ = units.add(b, c.perf_tests, null);
- _ = units.add(b, c.fs_bench_test, null);
+ _ = units.add(b, c.tools.perf_tests, null);
+ _ = units.add(b, c.tools.fs_bench_test, null);
if (c.cells_test) |t| _ = units.add(b, t, null);
if (c.atlas_test) |t| _ = units.add(b, t, null);
const core_test = b.addTest(.{ .root_module = c.core_lean, .filters = c.test_filters });
@@ -70,7 +71,7 @@ pub fn add(b: *std.Build, c: struct {
core_test_step.dependOn(&run_core_test.step);
if (testMatch(b, c.unit_profile, c.test_filters, core_test_step)) |check| check.addArtifactArg(core_test);
// The terminal module's own tests (src/term/): the emulator without a core.
- const run_term_test = units.add(b, b.addTest(.{ .root_module = c.term_mod, .filters = c.test_filters }), null);
+ const run_term_test = units.add(b, b.addTest(.{ .root_module = c.parts.term, .filters = c.test_filters }), null);
b.step("term-test", "run the terminal module's own tests (src/term/)").dependOn(&run_term_test.step);
const pane_module = b.createModule(.{
.target = c.target,
@@ -80,9 +81,11 @@ pub fn add(b: *std.Build, c: struct {
});
pane_module.addImport("pardes", c.core_module);
// test/terminal.zig reads the emulator behind a core's terminal.
- pane_module.addImport("term", c.term_mod);
- pane_module.addImport("plain", c.plain_mod);
+ pane_module.addImport("term", c.parts.term);
+ pane_module.addImport("plain", c.parts.plain);
if (c.ghostty_vt_for_tests) |x| pane_module.addImport("ghostty-vt", x);
+ // The core's own options module, not another over the same file:
+ // a file is in one module of a compilation.
pane_module.addImport("pardes_config", c.core_module.import_table.get("pardes_config").?);
const test_addons = b.addOptions();
test_addons.addOptionPath("image", c.image_addon.getEmittedBin());
@@ -104,15 +107,7 @@ pub fn add(b: *std.Build, c: struct {
// The scripted language server its language words ask
// (Session.initLanguage), as the tty cases do.
const session_options = b.addOptions();
- session_options.addOptionPath("lspmock", b.addExecutable(.{
- .name = "pardes-lspmock",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/lspmock.zig"),
- .link_libc = true,
- }),
- }).getEmittedBin());
+ session_options.addOptionPath("lspmock", c.lspmock.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).
@@ -156,7 +151,7 @@ pub fn add(b: *std.Build, c: struct {
const snake_lib = b.addLibrary(.{ .name = "snake", .linkage = .dynamic, .root_module = snake_mod });
const life_mod = b.createModule(.{ .root_source_file = b.path("addons/life/life.zig"), .target = c.target, .optimize = c.optimize, .imports = &.{.{ .name = "addon", .module = c.addon_mod }} });
const life_lib = b.addLibrary(.{ .name = "life", .linkage = .dynamic, .root_module = life_mod });
- for ([_]*std.Build.Module{ snake_mod, life_mod, c.image_mod }) |m| addon_test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m })).step);
+ for ([_]*std.Build.Module{ snake_mod, life_mod, c.parts.image }) |m| addon_test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m })).step);
// ...and the pdf addon's, which mupdf-check runs too (its script
// opens docs/design.pdf, from the build root).
const libs = [_]struct { ?*std.Build.Step.Compile, []const u8 }{ .{ fake_addon_lib.?, "addons/fake/fake" }, .{ snake_lib, "addons/snake/snake" }, .{ c.snake_shader_lib, "addons/snake_shader/snake_shader" }, .{ life_lib, "addons/life/life" }, .{ c.pdf_addon, "addons/pdf/pdf" } };
@@ -178,16 +173,7 @@ pub fn add(b: *std.Build, c: struct {
// after each, random input hunting panics (`-- --monkey <seeds>`),
// and its seeds' tapes replayed (`-- --replay`). Bare, a short
// fixed-seed run of the first, part of behaviour-test.
- const t1_runner = b.addExecutable(.{
- .name = "pardes-monkey-session",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/monkey9p.zig"),
- .link_libc = true,
- }),
- });
- t1_runner.root_module.addImport("session", session_module);
+ const t1_runner = program(b, "pardes-monkey-session", "test/monkey9p.zig", c.target, c.optimize, &.{.{ .name = "session", .module = session_module }});
const run_t1_runner = b.addRunArtifact(t1_runner);
run_t1_runner.addPassthruArgs();
run_t1_runner.has_side_effects = true;
@@ -215,10 +201,9 @@ pub fn add(b: *std.Build, c: struct {
.{ .path = "src/9p_io.zig", .step = "9p-io-test", .about = "run native 9P transport and client integration tests", .filters = &.{ "Unix and TCP", "one fetch", "expired sessions", "posts itself" } },
.{ .path = "src/fs.zig", .step = "fs-unit-test", .about = "run filesystem unit tests", .filters = c.test_filters },
}) |t| {
- const m = b.createModule(.{ .root_source_file = b.path(t.path), .target = c.target, .optimize = c.optimize, .link_libc = true });
- m.link_objects.appendSlice(b.allocator, c.core_module.link_objects.items) catch @panic("OOM");
- var imports = c.core_module.import_table.iterator();
- while (imports.next()) |entry| m.addImport(entry.key_ptr.*, entry.value_ptr.*);
+ var cfg = c.core_cfg;
+ cfg.root = t.path;
+ const m = core.module(b, c.parts, cfg);
b.step(t.step, t.about).dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m, .filters = t.filters })).step);
}
@@ -241,7 +226,7 @@ pub fn add(b: *std.Build, c: struct {
}),
.filters = c.test_filters,
});
- tests.root_module.addImport("cloud9", c.cloud9);
+ tests.root_module.addImport("cloud9", c.parts.cloud9);
const run_tests = units.add(b, tests, null);
if (std.mem.eql(u8, entry.path, "src/9p.zig")) {
protocol_step.dependOn(&run_tests.step);