diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-25 11:05:21 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-25 12:28:58 -0300 |
| commit | e5f9e172330bc4500995ddd5954ed94f94e07af6 (patch) | |
| tree | aa7c5079b4c2951cef5b5c15595d0b20bc3ae245 /build.zig | |
| parent | 6f48508aa08396bcf9dd4da2cab1d221bcc53f78 (diff) | |
| download | pardes-e5f9e172330bc4500995ddd5954ed94f94e07af6.tar.gz pardes-e5f9e172330bc4500995ddd5954ed94f94e07af6.zip | |
tests: a capture is a delta and a click names its word, so a tagline edit stops rewriting the suite
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -76,6 +76,12 @@ pub fn build(b: *std.Build) void { const requested_optimize = b.standardOptimizeOption(.{}); const static = b.option(bool, "static", "statically link") orelse false; const dump_path = b.option([]const u8, "dump", "dump .zon embedded into the web shell (-Dplatform=web)"); + // one substring, because that is what a dev loop needs: see the unit-test + // step for why the whole-binary run is worth narrowing + const test_filters: []const []const u8 = if (b.option([]const u8, "test-filter", "run only tests whose name contains this")) |f| + &.{f} + else + &.{}; const is_web = platform == .web; const enable_mupdf = b.option(bool, "mupdf", "native PDF rendering with MuPDF (AGPL/commercial; native default on, web off; -Dmupdf=false disables)") orelse !is_web; // JPEG 2000, and with it scanned PDFs: a scan is one /JPXDecode image per @@ -243,7 +249,12 @@ pub fn build(b: *std.Build) void { .name = "pardes-gen-themes", .root_module = b.createModule(.{ .target = b.graph.host, - .optimize = .ReleaseSafe, + // Debug on purpose: it runs for ~40ms, and every core module + // imports what it generates, so its compile is the first link of + // every cold build. ReleaseSafe cost 16s of compile to save 47ms of + // run time, and the 226 files it writes are byte-identical either + // way. + .optimize = .Debug, .root_source_file = b.path("tools/gen_themes.zig"), }), }); @@ -1025,7 +1036,7 @@ pub fn build(b: *std.Build) void { // configuration theirs is not declared. macos.zig imports the core, so // this one aggregate reaches both the C-ABI guard and the core tests. const unit_step = b.step("unit-test", "run the C-ABI guard and core unit tests"); - unit_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = root_mod })).step); + unit_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = root_mod, .filters = test_filters })).step); web_step.dependOn(&b.addFail("web needs -Dplatform=web -Dtarget=wasm32-freestanding -Ddump=<dump.zon>").step); } else { // binary name: the native-shaped linux-x86_64 tty build stays `pardes` @@ -1295,8 +1306,15 @@ pub fn build(b: *std.Build) void { // runtime switch, which test analysis never enters. main.zig's test // block names the selected shell, user config, and platform-only // helpers; its ordinary core import reaches pardes.zig and modal.zig. + // + // `-Dtest-filter=<substring>` narrows it. The whole binary is 14s and + // two tests are 8.6s of that, so a one-line change to a module with a + // three-millisecond test used to cost the full run: `zig build + // unit-test -Dtest-filter="an untouched tagline"` is ~1s. The test + // runner's own `--test-filter` never worked here - nothing forwarded + // `--` args to the run step, so it was parsed as a script name. if (platform == .tty or platform == .gui) { - const shell_test = b.addTest(.{ .root_module = root_mod }); + const shell_test = b.addTest(.{ .root_module = root_mod, .filters = test_filters }); unit_step.dependOn(&b.addRunArtifact(shell_test).step); } } |
