summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/consumer/bench.zig (renamed from test/lib/bench.zig)0
-rw-r--r--test/consumer/build.zig42
-rw-r--r--test/consumer/build.zig.zon16
-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.zig34
-rw-r--r--test/lib/build.zig.zon10
7 files changed, 58 insertions, 44 deletions
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,
-}