summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/panes.zig1
-rw-r--r--test/behaviour/settings.zig2
-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/fs_namespace.zig3
-rw-r--r--test/lib/build.zig34
-rw-r--r--test/lib/build.zig.zon10
-rw-r--r--test/output.zig11
-rw-r--r--test/panes.zig12
-rw-r--r--test/terminal.zig2
13 files changed, 60 insertions, 73 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index dcde9c4d..4d4c812c 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -888,7 +888,6 @@ test "panes: truncating body empties it, and a stat says the length after" {
}
test "panes: a rename colours a source its new name's language names, its text unchanged" {
- if (@import("pardes_options").grammars == .disabled) return error.SkipZigTest;
var s = try Session.initFile(std.testing.allocator, "fn check() void {}\n");
defer s.deinit();
const n = try s.focused();
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index cacee701..a6e09f35 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -158,7 +158,6 @@ test "settings: Back and Forward written to exec keep to the focused file" {
});
}
-const syntax = @import("pardes_options").grammars != .disabled;
/// The style /screen draws the cell `into` cells into the first place
/// `text` is drawn.
@@ -190,7 +189,6 @@ fn keywordsIn(s: *Session, want: []const u8) !usize {
}
test "settings: keywords stay coloured in every row a pane grows into" {
- if (!syntax) return error.SkipZigTest;
var s = try Session.initFile(std.testing.allocator, std.mem.asBytes(&@as([100][33]u8, @splat("pub fn f() void { if (true) {} }\n".*))));
defer s.deinit();
try s.write(s.at("/pane/{d}/name", .{try s.focused()}), "/resize.zig\n");
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/fs_namespace.zig b/test/fs_namespace.zig
index ceda8158..90b610a9 100644
--- a/test/fs_namespace.zig
+++ b/test/fs_namespace.zig
@@ -118,7 +118,6 @@ test "transactional restore preserves host capabilities and advances pane identi
}
test "filesystem resolves OS first then virtual with explicit mounts and parent paths" {
- if (!filesystem.platform_has_fs) return error.SkipZigTest;
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -185,7 +184,6 @@ test "filesystem resolves OS first then virtual with explicit mounts and parent
}
test "explicit OS file opens and restores keep their names and request watches" {
- if (!filesystem.platform_has_fs) return error.SkipZigTest;
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -286,7 +284,6 @@ test "owned cwd failed file opens never publish a pane or retain a reservation"
}
test "images decode through explicit filesystem mounts, and a dump's pane reads its file again through the same mount" {
- if (!filesystem.platform_has_fs) return error.SkipZigTest;
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
diff --git a/test/lib/build.zig b/test/lib/build.zig
deleted file mode 100644
index 436517d4..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, .@"tree-sitter" = .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,
-}
diff --git a/test/output.zig b/test/output.zig
index c5ddddd5..77de7649 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -138,7 +138,7 @@ test "location producers retain rendered location match and diagnostic styles" {
} else if (origin == .search or origin == .cmd) {
try std.testing.expectEqual(pardes.Color{ .rgb = chrome.search_bg }, first.style.bg);
}
- if (!diagnostic and pardes.syntax.enabled) {
+ if (!diagnostic) {
const number = start + std.mem.indexOf(u8, code, "42").?;
try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().num }, outputCell(p, surface, id, number).style.fg);
}
@@ -428,7 +428,6 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo
}
test "Mini syntax colors survive themes and rendering without source access" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "demo.zig", .data = "pub fn main() void {\n if (true) return;\n}\n" });
@@ -619,7 +618,6 @@ fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 {
}
test "LookNext/LookPrev skips formatted context and selects comment match locations" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| {
for ([_]bool{ false, true }) |tslocations| {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
@@ -786,7 +784,7 @@ test "identical result refresh keeps warm content caches without allocation" {
const index = try panes.File.lineIndex(p.gpa, file);
const styles = try std.testing.allocator.dupe(u8, file.highlights);
defer std.testing.allocator.free(styles);
- if (@import("pardes_options").grammars != .disabled) try std.testing.expect(styles.len > 0);
+ try std.testing.expect(styles.len > 0);
const revision = file.revision;
const saved_revision = file.saved_revision;
const body_ptr = file.content.ptr;
@@ -1048,7 +1046,6 @@ test "result alignment chunks assign boundary context to nearest match with prev
}
test "declaration context ellipses mark only final header lines before omitted source" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const text = "const Outer = struct {\n" ++
"\n" ++
" pub fn run(\n" ++
@@ -1161,7 +1158,6 @@ test "LSP occurrence tint follows the supplied source span through context" {
}
test "result context upper bound stops at earliest enclosing declaration" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const text = "// unrelated prelude\n" ++
"const unrelated = 1;\n" ++
"\n" ++
@@ -1227,7 +1223,6 @@ test "result context upper bound stops at earliest enclosing declaration" {
}
test "stacked search and LSP results retain source tint navigation and dump ownership" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const first = "\tfoo + 界 + foo;";
const second = " return foo;";
const source_text = "const Box = struct {\n fn run() void {\n" ++ first ++ "\n const neighbor = 42;\n" ++ second ++ "\n }\n};\n";
@@ -1348,7 +1343,6 @@ test "stacked search and LSP results retain source tint navigation and dump owne
}
test "location analysis cache refreshes unsaved ancestry and query context" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
const before = "const Outer = struct {\n" ++
" fn first() void {\n" ++
" marker();\n" ++
@@ -1429,7 +1423,6 @@ test "location analysis cache refreshes unsaved ancestry and query context" {
}
test "location cache eviction retains early colors and honors disk and unsaved replacements" {
- if (!pardes.syntax.enabled) return error.SkipZigTest;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
var dir_buf: [4096]u8 = undefined;
diff --git a/test/panes.zig b/test/panes.zig
index dbdbec2f..6bda3519 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -152,7 +152,6 @@ const BodyHitTests = struct {
}
test "compact TreeContext mouse follows source rows in reclaimed space" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
@@ -201,7 +200,6 @@ const BodyHitTests = struct {
const LineNumberLookTests = struct {
test "right-click on a line number looks at that line, sticky context headers included" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
@@ -259,7 +257,6 @@ const TreeContextTests = struct {
}
test "TreeContext separators mark source gaps without splitting multiline signatures" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, "const Box = struct {\n\n // omitted member comment\n\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([30][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
@@ -291,7 +288,6 @@ const TreeContextTests = struct {
test "TreeContext Look to an open file discards the old viewport extent" {
for ([_]bool{ false, true }) |context| {
- if (context and !syntax.enabled) continue;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, "pub fn work() void {\n" ++ std.mem.asBytes(&@as([100][12]u8, @splat(" // body\n".*))) ++ "}\n");
@@ -316,7 +312,6 @@ const TreeContextTests = struct {
}
test "TreeContext sticky declarations preserve the body while clicked and edited" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, source);
@@ -368,7 +363,6 @@ const TreeContextTests = struct {
}
test "TreeContext unwrapped headers map Unicode and survive source replacement" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 48, .rows = 14 });
defer p.deinit();
const pane = try setZigFile(p, "pub fn @\"界name\"(\n\tvalue: usize,\n) void {\n" ++ std.mem.asBytes(&@as([12][15]u8, @splat(" _ = value;\n".*))) ++ "}\n");
@@ -407,7 +401,6 @@ const TreeContextTests = struct {
}
test "TreeContext clipped headers leave wrapped body cursor coordinates intact" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 24, .rows = 12 });
defer p.deinit();
const body = " // 012345678901234567890123456789界tail";
@@ -1717,7 +1710,6 @@ const OutputTests = struct {
}
test "Callstack aligns source below locations and keeps exact emphasis and navigation" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 30 });
defer p.deinit();
const source = " pub fn caller(\n value: u32,\n ) void {\n work(value);\n }\n";
@@ -1759,7 +1751,6 @@ const OutputTests = struct {
}
test "Callstack signatures share unsaved tree context and keep guides out of Look selections" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 110, .rows = 30 });
defer p.deinit();
const source = "const Box = struct {\n" ++
@@ -1853,7 +1844,6 @@ const OutputTests = struct {
}
test "Locations context uses unsaved sources and navigation visits only matches" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -1968,7 +1958,6 @@ const OutputTests = struct {
}
test "Locations visible declarations are muted and stars count scopes rather than signature lines" {
- if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -3541,7 +3530,6 @@ test "cancelled normal gestures leave no count or subprefix through raw tty mode
}
test "Zig keywords keep every rendered byte colored across line-number widths" {
- if (!syntax.enabled) return error.SkipZigTest;
const gpa = std.testing.allocator;
const samples = [_][]const u8{
"pub fn main() void { if (true) {} }\n",
diff --git a/test/terminal.zig b/test/terminal.zig
index b7b9cd33..ec050c7a 100644
--- a/test/terminal.zig
+++ b/test/terminal.zig
@@ -203,7 +203,6 @@ test "a terminal's dump restores the cells it drew, its history and where its vi
}
test "a restored command pane comes back finished, its command not run again" {
- if (comptime pardes.isolated) return error.SkipZigTest;
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 });
defer p.deinit();
@@ -233,7 +232,6 @@ test "a restored command pane comes back finished, its command not run again" {
}
test "a restored terminal keeps its history above a marker and gets a shell where it was" {
- if (comptime pardes.isolated) return error.SkipZigTest;
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 });
defer p.deinit();