diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 04:38:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 04:39:53 -0300 |
| commit | 403b46922af6e4e2012cd15f5f3f5a5702eef7e7 (patch) | |
| tree | 44e4df5fbc12e77210fbcafa50f29d23c93caa05 | |
| parent | a3634ab3dbf2fabd997f137c47eafd7bc6c442b0 (diff) | |
| download | pardes-403b46922af6e4e2012cd15f5f3f5a5702eef7e7.tar.gz pardes-403b46922af6e4e2012cd15f5f3f5a5702eef7e7.zip | |
test: test/lib becomes test/consumer, the package a consumer would write, in both of build.zig's head-comment shapes (pardes-build-2 item 5; the start design's step 3): `pardes-syntax` with `.grammars = .minimal` (lib.zig, as before), and `pardes-editor` with `.grammars = .none, .editor = true` and a grammar of its own, C's, built by this package from the very package pardes's manifest pins (`ts_c`, its own build's `tree-sitter-c` artifact, static, ReleaseFast) and linked into the editor's test and the bench, so the case sketchbook's examples/live is (pardes compiles no grammar for it; the program hands one in at run time) is gated here and not only in sketchbook; no network: `lib-test` runs it with `--pkg-dir ../../zig-pkg`, which has that package; the package is named `pardes_consumer` (a new fingerprint, as zig asks for a renamed package); lib-test's run step is named for what it is, so `--summary all` shows `zig build test in test/consumer, a package that depends on pardes success`, under `unit-test` as before; the package's own run: 29/29 steps, 11/11 tests (3 of the syntax, 8 of the editor), its bench builds and runs; build/tools.zig, build.zig's head comment, core/lib_syntax.zig, docs/next-editor.md, the manual and the changelog name test/consumer; the stale `test/lib/zig-pkg` (1.1 GB, untracked, from a run without --pkg-dir) deleted with the old directory. Scripts and notes outside the tree that name test/lib (its cache among them: a wipe of `test/lib/.zig-cache` now misses `test/consumer/.zig-cache`) are listed in the agent's report for the coordinator
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | build.zig | 5 | ||||
| -rw-r--r-- | build/tools.zig | 7 | ||||
| -rw-r--r-- | core/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | core/lib_syntax.zig | 2 | ||||
| -rw-r--r-- | docs/next-editor.md | 4 | ||||
| -rw-r--r-- | docs/typ/building.typ | 4 | ||||
| -rw-r--r-- | test/consumer/bench.zig (renamed from test/lib/bench.zig) | 0 | ||||
| -rw-r--r-- | test/consumer/build.zig | 42 | ||||
| -rw-r--r-- | test/consumer/build.zig.zon | 16 | ||||
| -rw-r--r-- | test/consumer/editor.zig (renamed from test/lib/editor.zig) | 0 | ||||
| -rw-r--r-- | test/consumer/lib.zig (renamed from test/lib/lib.zig) | 0 | ||||
| -rw-r--r-- | test/lib/build.zig | 34 | ||||
| -rw-r--r-- | test/lib/build.zig.zon | 10 |
13 files changed, 71 insertions, 55 deletions
@@ -22,8 +22,9 @@ //! Every dependency but tree-sitter's runtime is lazy in the manifest, so //! such a package fetches what it asked for and nothing else. //! `pardes-editor` has `pardes-syntax` in it as `.syntax`: a file belongs -//! to one module, so a package imports one of the two. test/lib is such a -//! package; `lib-test`, which `unit-test` runs, builds and runs it. +//! to one module, so a package imports one of the two. test/consumer is +//! such a package, with both shapes; `lib-test`, which `unit-test` runs, +//! builds and runs it. const std = @import("std"); const builtin = @import("builtin"); const core = @import("build/core.zig"); diff --git a/build/tools.zig b/build/tools.zig index 62e9817a..a4b41dd7 100644 --- a/build/tools.zig +++ b/build/tools.zig @@ -250,12 +250,13 @@ pub fn add(b: *std.Build, c: struct { if (testMatch(b, c.unit_profile, c.test_filters, syntax_test_step)) |check| check.addArtifactArg(syntax_test); // The library as a package that depends on pardes is given it - // (`library`): test/lib's own `zig build test`, over the packages + // (`library`): test/consumer's own `zig build test`, over the packages // this checkout has fetched. const lib_test = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "test", "--pkg-dir", "../../zig-pkg" }); - lib_test.setCwd(b.path("test/lib")); + lib_test.setName("zig build test in test/consumer, a package that depends on pardes"); + lib_test.setCwd(b.path("test/consumer")); lib_test.has_side_effects = true; - const lib_test_step = b.step("lib-test", "build and test the library from a package that depends on pardes (test/lib)"); + const lib_test_step = b.step("lib-test", "build and test the library from a package that depends on pardes (test/consumer)"); lib_test_step.dependOn(&lib_test.step); const history = b.addExecutable(.{ diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 813f24e6..5c9ac98c 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -214,7 +214,7 @@ dependency but tree-sitter's runtime is lazy in the manifest, so such a package fetches the runtime and the grammars of its `grammars` set and nothing else; `zig build lib-test`, which `unit-test` runs, builds - one (`test/lib`). The markdown grammar is pinned by its commit: its + one (`test/consumer`). The markdown grammar is pinned by its commit: its branch has moved, and a fresh checkout could not fetch it. - Enter, `o` and `O` give the new line helix's indent where the file's diff --git a/core/lib_syntax.zig b/core/lib_syntax.zig index f10f88a5..f4f85820 100644 --- a/core/lib_syntax.zig +++ b/core/lib_syntax.zig @@ -4,7 +4,7 @@ //! coloured as pardes has it. Nothing is copied here: these are the editor's //! own grammars and highlighting (syntax.zig), themes (colors.zig) and line //! arithmetic (modal.zig), under the names they have there. Whatever is -//! named here compiles with tree-sitter and the grammars alone; test/lib +//! named here compiles with tree-sitter and the grammars alone; test/consumer //! imports it as such a package and holds it to that. //! //! A language is told by a path's extension, as in the editor; `pathFor` diff --git a/docs/next-editor.md b/docs/next-editor.md index e7168256..4b62f6b0 100644 --- a/docs/next-editor.md +++ b/docs/next-editor.md @@ -72,7 +72,7 @@ registers before it writes anything. A ring never refuses: it drops its oldest snapshots, never part of one (an undo ring holds at least one whole text, checked at compile time). -**Measured** (test/lib `zig build bench`, a text in C's shape, a key typed +**Measured** (test/consumer `zig build bench`, a text in C's shape, a key typed into its middle, 200 keys, this machine): a key at 1, 16, 64 KiB is 13, 173 and 692 µs in Debug (270k, 3.1M, 12.2M instructions) and 0.7, 7.7 and 30 µs in ReleaseFast: the 64 KiB key is 4% of a 16 ms frame in Debug. A @@ -82,7 +82,7 @@ text's and the cursor's); the first after a jump moves the gap, 3, 5 and optimised in every mode): once a changed key, not a frame, so no incremental re-parse. -A package taking the editor (test/lib) compiles cold in 6.4 s (126e9 +A package taking the editor (test/consumer) compiles cold in 6.4 s (126e9 instructions), an edit of its own file in 0.95 s plainly and 0.09-0.11 s under `--watch -fincremental`. pardes itself: core-test's full recompile 238.8e9 instructions before and after; the typing cells of `zig build diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 8403df9a..8d14374d 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -130,7 +130,7 @@ what it is missing in one round. Zig still unpacks a lazy package whose archive its global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) at pardes's `zig-pkg` shares the one copy. What a pane measures stays out: a cell's width is vaxis's and uucode's, and a tab is -`config.tab_width` cells wherever it stands. `test/lib` is such a +`config.tab_width` cells wherever it stands. `test/consumer` is such a package, and `zig build lib-test` builds and runs it. === The editor @@ -186,7 +186,7 @@ zig build kitty-harness kitty graphics through a pane end to end (a fake kitt kitten icat and chafa too when installed) zig build syntax-test tree-sitter tests without building the editor zig build syntax deterministic per-byte highlighting snapshots -zig build lib-test the library, from a package that depends on pardes (test/lib); +zig build lib-test the library, from a package that depends on pardes (test/consumer); unit-test runs it too zig build hxlib helix's cases on the library's editor (-- --parity: against the file pane) zig build behaviour-test behaviour through the 9P tree, in process (test/behaviour/), diff --git a/test/lib/bench.zig b/test/consumer/bench.zig index 7e945064..7e945064 100644 --- a/test/lib/bench.zig +++ b/test/consumer/bench.zig diff --git a/test/consumer/build.zig b/test/consumer/build.zig new file mode 100644 index 00000000..ca63bb6e --- /dev/null +++ b/test/consumer/build.zig @@ -0,0 +1,42 @@ +//! A package that depends on pardes, as a program would (build.zig's head +//! comment has its lines): pardes's `lib-test`, which `unit-test` runs, +//! runs `zig build test` here. `pardes-syntax` with the minimal grammars, +//! as a program that draws source text itself takes it; and +//! `pardes-editor` with no grammar of pardes's and one of its own, C's, +//! compiled here from the package pardes pins and handed in at run time, +//! as sketchbook's `examples/live` takes it. +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + const syntax = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .minimal }); + const editor = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .none, .editor = true }); + // The grammar of its own: C's, from the package pardes's manifest pins + // (so `--pkg-dir` at pardes's zig-pkg has it), as that package builds it. + const grammar = b.dependency("ts_c", .{ .target = target, .optimize = .ReleaseFast, .@"build-shared" = false }).artifact("tree-sitter-c"); + const step = b.step("test", "colour, outline and walk a C and a Zig source through pardes's syntax, and edit a text with its editor and a grammar of this package's"); + // A file belongs to one module: the syntax alone, and the editor (which + // has it as `.syntax`), each a test of its own. + for ([_]struct { []const u8, []const u8, *std.Build.Dependency }{ .{ "lib.zig", "pardes-syntax", syntax }, .{ "editor.zig", "pardes-editor", editor } }) |t| { + const mod = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path(t[0]), + .imports = &.{.{ .name = t[1], .module = t[2].module(t[1]) }}, + }); + if (t[2] == editor) mod.linkLibrary(grammar); + step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mod })).step); + } + // What a key costs, a page count and a parse: `zig build bench -- <KiB> <keys>`. + const bench = b.addExecutable(.{ .name = "bench", .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("bench.zig"), + .imports = &.{.{ .name = "pardes-editor", .module = editor.module("pardes-editor") }}, + }) }); + bench.root_module.linkLibrary(grammar); + const run_bench = b.addRunArtifact(bench); + run_bench.addPassthruArgs(); + b.step("bench", "a key typed into the library's editor at a size, its pages and a parse").dependOn(&run_bench.step); +} diff --git a/test/consumer/build.zig.zon b/test/consumer/build.zig.zon new file mode 100644 index 00000000..c367775b --- /dev/null +++ b/test/consumer/build.zig.zon @@ -0,0 +1,16 @@ +.{ + .name = .pardes_consumer, + .version = "0.0.0", + .dependencies = .{ + .pardes = .{ .path = "../.." }, + // The grammar this package hands pardes's editor: the one pardes's + // own manifest pins, so `--pkg-dir` at its zig-pkg has it. + .ts_c = .{ + .url = "git+https://github.com/pierrelgol/tree-sitter-c#67949e4c8dc630c18a522919f2bde2e025a0d025", + .hash = "tree_sitter_c-0.24.2-y5boS-htQACe3pz6jHq4tpS8dB6WIo4-zk_ct7lAjvQT", + }, + }, + .minimum_zig_version = "0.17.1", + .paths = .{""}, + .fingerprint = 0xb5ce4ba417a79812, +} diff --git a/test/lib/editor.zig b/test/consumer/editor.zig index 22690915..22690915 100644 --- a/test/lib/editor.zig +++ b/test/consumer/editor.zig diff --git a/test/lib/lib.zig b/test/consumer/lib.zig index 7e297920..7e297920 100644 --- a/test/lib/lib.zig +++ b/test/consumer/lib.zig diff --git a/test/lib/build.zig b/test/lib/build.zig deleted file mode 100644 index 171812e9..00000000 --- a/test/lib/build.zig +++ /dev/null @@ -1,34 +0,0 @@ -//! A package that depends on pardes for its library, as a program that draws -//! source text itself would: pardes's `lib-test` step runs `zig build test` -//! here, so the `pardes-syntax` module is built the way such a package -//! builds it (build.zig's `library`), with the minimal grammars, and -//! `pardes-editor`, the text pane as a library, which it asks for. -const std = @import("std"); - -pub fn build(b: *std.Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .minimal, .editor = true }); - const step = b.step("test", "colour, outline and walk a C and a Zig source through pardes's library, and edit a text with its editor"); - // A file belongs to one module: the syntax alone, and the editor (which - // has it as `.syntax`), each a test of its own. - for ([_][2][]const u8{ .{ "lib.zig", "pardes-syntax" }, .{ "editor.zig", "pardes-editor" } }) |t| { - const tests = b.addTest(.{ .root_module = b.createModule(.{ - .target = target, - .optimize = optimize, - .root_source_file = b.path(t[0]), - .imports = &.{.{ .name = t[1], .module = pardes.module(t[1]) }}, - }) }); - step.dependOn(&b.addRunArtifact(tests).step); - } - // What a key costs, a page count and a parse: `zig build bench -- <KiB> <keys>`. - const bench = b.addExecutable(.{ .name = "bench", .root_module = b.createModule(.{ - .target = target, - .optimize = optimize, - .root_source_file = b.path("bench.zig"), - .imports = &.{.{ .name = "pardes-editor", .module = pardes.module("pardes-editor") }}, - }) }); - const run_bench = b.addRunArtifact(bench); - run_bench.addPassthruArgs(); - b.step("bench", "a key typed into the library's editor at a size, its pages and a parse").dependOn(&run_bench.step); -} diff --git a/test/lib/build.zig.zon b/test/lib/build.zig.zon deleted file mode 100644 index d8c31c3f..00000000 --- a/test/lib/build.zig.zon +++ /dev/null @@ -1,10 +0,0 @@ -.{ - .name = .pardes_lib_test, - .version = "0.0.0", - .dependencies = .{ - .pardes = .{ .path = "../.." }, - }, - .minimum_zig_version = "0.17.1", - .paths = .{""}, - .fingerprint = 0x3f9948734dd377c7, -} |
