summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/tests.zig97
-rw-r--r--build/tools.zig24
2 files changed, 30 insertions, 91 deletions
diff --git a/build/tests.zig b/build/tests.zig
index efb3515f..5417c54a 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -58,10 +58,10 @@ pub fn add(b: *std.Build, c: struct {
// contrast search per grapheme costs 100x, far past the gate).
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 };
+ 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, .target = c.target, .optimize = c.optimize };
// The perf and fs bench programs' own tests: they compile no editor.
- _ = units.add(b, c.tools.perf_tests, null);
- _ = units.add(b, c.tools.fs_bench_test, null);
+ _ = units.add(b, units.root(b, "test/perf.zig", true, &.{.{ .name = "perf_options", .module = c.tools.perf_options.createModule() }}), null);
+ _ = units.add(b, units.root(b, "test/fs_bench.zig", null, &.{}), 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 });
@@ -73,26 +73,17 @@ pub fn add(b: *std.Build, c: struct {
// 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.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,
- .optimize = c.optimize,
- .root_source_file = b.path("test/panes.zig"),
- .link_libc = true,
- });
- pane_module.addImport("pardes", c.core_module);
// test/terminal.zig reads the emulator behind a core's terminal.
- 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);
+ const pane_tests = units.root(b, "test/panes.zig", true, &.{ .{ .name = "pardes", .module = c.core_module }, .{ .name = "term", .module = c.parts.term }, .{ .name = "plain", .module = c.parts.plain } });
+ if (c.ghostty_vt_for_tests) |x| pane_tests.root_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").?);
+ pane_tests.root_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());
test_addons.addOption(bool, "has_pdf", c.pdf_addon != null);
if (c.pdf_addon) |l| test_addons.addOptionPath("pdf", l.getEmittedBin());
- pane_module.addOptions("test_addons", test_addons);
- const pane_tests = b.addTest(.{ .root_module = pane_module, .filters = c.test_filters });
+ pane_tests.root_module.addOptions("test_addons", test_addons);
_ = units.add(b, pane_tests, b.step("pane-test", "run pane, output and namespace integration tests"));
// The behavioural tests (docs/next-tests.md): their module has the
@@ -130,17 +121,9 @@ pub fn add(b: *std.Build, c: struct {
session_options.addOption(bool, "has_pdf_addon", c.pdf_addon != null);
if (c.pdf_addon) |l| session_options.addOptionPath("pdf_addon", l.getEmittedBin());
session_module.addOptions("session_options", session_options);
- const behaviour_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/behaviour.zig"),
- .link_libc = true,
- });
- behaviour_module.addImport("session", session_module);
// The build's options alone (platform), never the core: a test of a
// window's word knows which build it runs in.
- behaviour_module.addImport("pardes_config", c.core_module.import_table.get("pardes_config").?);
- const behaviour_tests = b.addTest(.{ .root_module = behaviour_module, .filters = c.test_filters });
+ const behaviour_tests = units.root(b, "test/behaviour.zig", true, &.{ .{ .name = "session", .module = session_module }, .{ .name = "pardes_config", .module = c.core_module.import_table.get("pardes_config").? } });
const behaviour_test_step = b.step("behaviour-test", "run the behavioural tests, through the 9P tree alone (test/behaviour/), and the T1 runner (-- [--seed N]... | --monkey <seeds> | --replay)");
_ = units.add(b, behaviour_tests, behaviour_test_step);
// An addon's own test: `--addon-test` over the fake (the template)
@@ -183,15 +166,7 @@ pub fn add(b: *std.Build, c: struct {
// program sends, what it reads back, what ghostty stores and what a
// frame draws (test/kitty.zig). The end-to-end arm, through a real
// pty and the shell's output, is the kitty-harness step.
- const kitty_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/kitty.zig"),
- .link_libc = true,
- });
- kitty_module.addImport("pardes", c.core_module);
- const kitty_tests = b.addTest(.{ .root_module = kitty_module, .filters = c.test_filters });
- _ = units.add(b, kitty_tests, b.step("kitty-test", "run the kitty graphics conformance cases for terminal panes"));
+ _ = units.add(b, units.root(b, "test/kitty.zig", true, &.{.{ .name = "pardes", .module = c.core_module }}), b.step("kitty-test", "run the kitty graphics conformance cases for terminal panes"));
// 9p_io.zig's and fs.zig's tests as roots of their own, on the
// core's imports and C libraries: native transport integration
@@ -207,44 +182,18 @@ pub fn add(b: *std.Build, c: struct {
b.step(t.step, t.about).dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m, .filters = t.filters })).step);
}
+ const cloud9: []const std.Build.Module.Import = &.{.{ .name = "cloud9", .module = c.parts.cloud9 }};
+ _ = units.add(b, units.root(b, "test/history.zig", false, cloud9), null);
+ const protocol_tests = units.root(b, "src/9p.zig", false, cloud9);
const protocol_step = b.step("9p-test", "run freestanding 9P protocol tests");
- const protocol_match = testMatch(b, c.unit_profile, c.test_filters, protocol_step);
- for ([_]struct { path: []const u8, libc: bool, optimize: ?std.builtin.OptimizeMode = null }{
- .{ .path = "test/history.zig", .libc = false },
- .{ .path = "src/9p.zig", .libc = false },
- .{ .path = "src/fonts.zig", .libc = true },
- .{ .path = "src/c_heap.zig", .libc = false },
- // Its lookup goes wrong only where the optimizer folds it.
- .{ .path = "src/c_heap.zig", .libc = false, .optimize = .ReleaseSafe },
- }) |entry| {
- const tests = b.addTest(.{
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = entry.optimize orelse c.optimize,
- .root_source_file = b.path(entry.path),
- .link_libc = entry.libc,
- }),
- .filters = c.test_filters,
- });
- 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);
- if (protocol_match) |check| check.addArtifactArg(tests);
- }
- }
+ protocol_step.dependOn(&units.add(b, protocol_tests, null).step);
+ if (testMatch(b, c.unit_profile, c.test_filters, protocol_step)) |check| check.addArtifactArg(protocol_tests);
+ _ = units.add(b, units.root(b, "src/fonts.zig", true, cloud9), null);
+ _ = units.add(b, units.root(b, "src/c_heap.zig", false, cloud9), null);
+ // Its lookup goes wrong only where the optimizer folds it.
+ _ = units.add(b, b.addTest(.{ .root_module = b.createModule(.{ .target = c.target, .optimize = .ReleaseSafe, .root_source_file = b.path("src/c_heap.zig"), .link_libc = false, .imports = cloud9 }), .filters = c.test_filters }), null);
- const deck_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/deck/replay.zig"),
- });
- deck_module.addImport("deck", b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("src/gui/deck.zig"),
- }));
- _ = units.add(b, b.addTest(.{ .root_module = deck_module, .filters = c.test_filters }), null);
+ _ = units.add(b, units.root(b, "test/deck/replay.zig", null, &.{.{ .name = "deck", .module = b.createModule(.{ .target = c.target, .optimize = c.optimize, .root_source_file = b.path("src/gui/deck.zig") }) }}), null);
if (c.platform == .tui or c.platform == .gui) {
const run_shell_test = units.add(b, b.addTest(.{ .root_module = c.root_mod, .filters = c.test_filters }), null);
@@ -280,6 +229,14 @@ const Units = struct {
match: ?*std.Build.Step.Run,
profiler: *std.Build.Step.Compile,
filters: []const []const u8,
+ target: std.Build.ResolvedTarget,
+ optimize: std.lang.Optimize,
+
+ /// A test program over `path` with `imports`, at this build's target
+ /// and optimization, filtered by -Dtest-filter.
+ fn root(u: Units, b: *std.Build, path: []const u8, link_libc: ?bool, imports: []const std.Build.Module.Import) *std.Build.Step.Compile {
+ return b.addTest(.{ .root_module = b.createModule(.{ .target = u.target, .optimize = u.optimize, .root_source_file = b.path(path), .link_libc = link_libc, .imports = imports }), .filters = u.filters });
+ }
/// `t` wired in, and run by `own` too, with a filter check of its own,
/// when it has a step of its own.
diff --git a/build/tools.zig b/build/tools.zig
index 4393e088..bcf073ef 100644
--- a/build/tools.zig
+++ b/build/tools.zig
@@ -15,8 +15,8 @@ pub fn program(b: *std.Build, name: []const u8, root: []const u8, target: std.Bu
/// What unit-test runs of what these make.
pub const Tools = struct {
perf_gate_step: *std.Build.Step,
- perf_tests: *std.Build.Step.Compile,
- fs_bench_test: *std.Build.Step.Compile,
+ /// The perf program's build identity, which its own tests read too.
+ perf_options: *std.Build.Step.Options,
lib_test_step: *std.Build.Step,
};
@@ -229,16 +229,6 @@ pub fn add(b: *std.Build, c: struct {
perf_gate.addArgs(&.{ "--only", "medium", "--reps", "10", "--base", b.fmt("test/perf-baseline-{t}-{t}.json", .{ c.platform, c.optimize }), "--max-ratio", "3" });
const perf_gate_step = b.step("perf-gate", "fail when a gesture on the 50k-line file takes over 3x its recorded baseline (test/perf-baseline-<platform>-<optimize>.json)");
perf_gate_step.dependOn(&perf_gate.step);
- const perf_tests = b.addTest(.{
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/perf.zig"),
- .link_libc = true,
- }),
- .filters = c.test_filters,
- });
- perf_tests.root_module.addOptions("perf_options", perf_options);
const fs_bench = program(b, "pardes-fs-bench", "test/fs_bench.zig", c.target, .fast, &.{.{ .name = "pardes", .module = c.core_module }});
const run_fs_bench = b.addRunArtifact(fs_bench);
@@ -247,14 +237,6 @@ pub fn add(b: *std.Build, c: struct {
run_fs_bench.setCwd(b.path("."));
const fs_bench_step = b.step("fs-bench", "9P filesystem request cost and allocation count (-- [--json] [--reps N])");
fs_bench_step.dependOn(&run_fs_bench.step);
- const fs_bench_test = b.addTest(.{
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/fs_bench.zig"),
- }),
- .filters = c.test_filters,
- });
// The syntax module's own tests and snapshots, on the core without
// a terminal: its tests reach the editor's modes (modal.zig).
@@ -297,7 +279,7 @@ pub fn add(b: *std.Build, c: struct {
run_history.addPassthruArgs();
run_history.has_side_effects = true;
b.step("history", "compare command output and test/build runtime across jj revisions").dependOn(&run_history.step);
- return .{ .perf_gate_step = perf_gate_step, .perf_tests = perf_tests, .fs_bench_test = fs_bench_test, .lib_test_step = lib_test_step };
+ return .{ .perf_gate_step = perf_gate_step, .perf_options = perf_options, .lib_test_step = lib_test_step };
}
/// The PDF benches: the core over the pdf addon, a pane of it.