diff options
| -rw-r--r-- | build/tools.zig | 13 | ||||
| -rw-r--r-- | core/File.zig | 1 | ||||
| -rw-r--r-- | core/Query.zig | 2 | ||||
| -rw-r--r-- | core/Stream.zig | 2 | ||||
| -rw-r--r-- | core/syntax.zig | 47 | ||||
| -rw-r--r-- | docs/typ/building.typ | 1 |
6 files changed, 38 insertions, 28 deletions
diff --git a/build/tools.zig b/build/tools.zig index a4b41dd7..2ed0e57e 100644 --- a/build/tools.zig +++ b/build/tools.zig @@ -229,8 +229,8 @@ pub fn add(b: *std.Build, c: struct { 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); - // The syntax module's own tests and snapshots, on the core without - // a terminal: its tests reach the editor's modes (modal.zig). + // The syntax module's snapshots, on the core without a terminal (its + // tests are core-test's, those named "syntax ..."). var syntax_cfg = c.lean; syntax_cfg.root = "core/syntax.zig"; const syntax_module = core.module(b, c.parts, syntax_cfg).root; @@ -239,15 +239,6 @@ pub fn add(b: *std.Build, c: struct { run_syntax.addPassthruArgs(); run_syntax.has_side_effects = true; b.step("syntax", "emit deterministic syntax snapshots (-- --bench: highlighting latency and allocations)").dependOn(&run_syntax.step); - const syntax_test = b.addTest(.{ - .root_module = syntax_module, - .filters = if (c.test_filters.len == 0) &.{"syntax "} else c.test_filters, - }); - const run_syntax_test = b.addRunArtifact(syntax_test); - run_syntax_test.has_side_effects = true; - const syntax_test_step = b.step("syntax-test", "test syntax correctness without building the editor"); - syntax_test_step.dependOn(&run_syntax_test.step); - 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/consumer's own `zig build test`, over the packages diff --git a/core/File.zig b/core/File.zig index ceb6d03b..8a8c05de 100644 --- a/core/File.zig +++ b/core/File.zig @@ -2312,6 +2312,7 @@ test "a pager's text is a diff when it holds a diff header or a unified hunk" { } test "a long line is painted only around the caret" { + if (comptime !syntax.full_grammars) return error.SkipZigTest; // JSON's const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); const line = try std.testing.allocator.alloc(u8, 600 << 10); diff --git a/core/Query.zig b/core/Query.zig index ebb44155..663095b0 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -2390,6 +2390,7 @@ test "Grep: lines of the files under the owner's directory, under their file; Al } test "* seeds line 1 and keeps the keyboard; SPC b b picks a pane, SPC s s a declaration" { + if (comptime !syntax.minimal_grammars) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 48 }); defer p.deinit(); const pane = try p.setTestFile("const alpha = 1;\nfn beta() void {\n _ = alpha;\n}\nfn gamma() void {}\n"); @@ -2624,6 +2625,7 @@ test "a query row's place is its text: the match tinted after it, B3 on it opens } test "the +Preview: the query's hits in its file are its places, the row's one current and selected, coloured as the file is" { + if (comptime !syntax.minimal_grammars) return error.SkipZigTest; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); const text = "const needle = 1;\nconst hay = 2;\nfn f() void {\n _ = needle;\n}\npub const needle_too = needle;\n"; diff --git a/core/Stream.zig b/core/Stream.zig index 1f4a7405..a04cad46 100644 --- a/core/Stream.zig +++ b/core/Stream.zig @@ -1266,6 +1266,7 @@ test "Stream: the listing of files for Find on a worker, a cap of hits stops the } test "Stream: a big text's declarations are parsed on a worker, never the loop, and the rows of its / regroup under them" { + if (comptime !syntax.minimal_grammars) return error.SkipZigTest; const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); defer p.deinit(); var text: std.ArrayList(u8) = .empty; @@ -1304,6 +1305,7 @@ test "Stream: a big text's declarations are parsed on a worker, never the loop, } test "Stream: a scroll's colours are painted ahead on a worker, so PageDown after PageDown parses nothing on the frame" { + if (comptime !syntax.minimal_grammars) return error.SkipZigTest; const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); defer p.deinit(); var text: std.ArrayList(u8) = .empty; diff --git a/core/syntax.zig b/core/syntax.zig index 19831ec2..00ee497f 100644 --- a/core/syntax.zig +++ b/core/syntax.zig @@ -7,8 +7,10 @@ const regexp = @import("regexp.zig"); const c_heap = @import("c_heap"); const diff = @import("diff.zig"); -const minimal_grammars = config.grammars != .none; -const full_grammars = config.grammars == .full; +/// The grammar sets built (`-Dgrammars`): a test that needs a grammar +/// not built skips. +pub const minimal_grammars = config.grammars != .none; +pub const full_grammars = config.grammars == .full; pub const ts = @import("tree-sitter"); const ts_queries = @import("ts_queries"); @@ -1260,6 +1262,7 @@ test "every vendored textobject and indent query compiles against its grammar" { } test "syntax context nested Zig containers and multiline function signatures" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1291,7 +1294,7 @@ test "syntax context nested Zig containers and multiline function signatures" { } test "syntax context Python class and function body excludes first statement" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1304,6 +1307,7 @@ test "syntax context Python class and function body excludes first statement" { } test "syntax context multiline bindings and C++ namespaces preserve declaration starts" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1313,7 +1317,7 @@ test "syntax context multiline bindings and C++ namespaces preserve declaration try std.testing.expectEqual(@as(usize, 1), zig_declarations.len); try std.testing.expectEqual(@as(usize, 0), zig_declarations[0].start_line); try std.testing.expectEqual(@as(usize, 1), zig_declarations[0].header_end_line); - if (!minimal_grammars) return; + if (!minimal_grammars) return error.SkipZigTest; const cpp_source = "namespace example {\nstruct Outer {\n int run() {\n return 1;\n }\n};\n}\n"; const cpp_declarations = try contextDeclarations(gpa, "nested.cpp", cpp_source); defer gpa.free(cpp_declarations); @@ -1325,7 +1329,7 @@ test "syntax context multiline bindings and C++ namespaces preserve declaration } test "syntax context Rust modules impls and methods remain nested" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1341,7 +1345,7 @@ test "syntax context Rust modules impls and methods remain nested" { } test "syntax formatted locations color hidden context and preserve multiline source" { - if (!minimal_grammars) return; + if (!minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1366,7 +1370,7 @@ test "syntax formatted locations color hidden context and preserve multiline sou } test "syntax formatted locations separate alignment from Markdown indentation" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1382,6 +1386,7 @@ test "syntax formatted locations separate alignment from Markdown indentation" { } test "syntax a results row is coloured by the file its location names" { + if (comptime !minimal_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const gpa = std.testing.allocator; @@ -1431,7 +1436,7 @@ test "syntax codeAfterLocation takes whole-token locations and nothing else" { } test "syntax default full grammar set highlights Typst source" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); @@ -1454,7 +1459,7 @@ test "syntax default full grammar set highlights Typst source" { } test "syntax Typst markup constructs paint and raw blocks inject their language" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); @@ -1498,7 +1503,7 @@ test "syntax Typst markup constructs paint and raw blocks inject their language" } test "syntax markdown highlights markup, injects inline spans and fenced code blocks" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); @@ -1530,7 +1535,7 @@ test "syntax markdown highlights markup, injects inline spans and fenced code bl } test "syntax inline fast path agrees with full Markdown query" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const selected = (try forLang("markdown_inline")).?; @@ -1577,7 +1582,7 @@ test "syntax inline fast path agrees with full Markdown query" { } test "syntax plain Markdown keeps block styles without starting the inline parser" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const source = "# Heading\n\nPlain prose.\n\n indented code\n"; @@ -1619,6 +1624,7 @@ test "syntax highlightDiff colors unified diff lines by prefix" { } test "syntax a Zig hunk is coloured as Zig, each side parsed whole" { + if (comptime !minimal_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const diff_text = @@ -1659,7 +1665,7 @@ test "syntax a Zig hunk is coloured as Zig, each side parsed whole" { } test "syntax a Python hunk is coloured as Python" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const diff_text = @@ -1680,6 +1686,7 @@ test "syntax a Python hunk is coloured as Python" { } test "syntax a deleted file's lines are coloured in its language" { + if (comptime !minimal_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const diff_text = @@ -1715,6 +1722,7 @@ test "syntax a hunk in no known language keeps the line colours" { } test "syntax git diff output in a command pane is told and coloured by its rows" { + if (comptime !minimal_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); // A command pane's rows: its command line, then git's output, with one @@ -1747,6 +1755,7 @@ test "syntax git diff output in a command pane is told and coloured by its rows" } test "syntax a section's small hunks share one parse" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1768,6 +1777,7 @@ test "syntax a section's small hunks share one parse" { } test "syntax a hunk painted once is kept, and a long one is parsed in pieces" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1856,6 +1866,7 @@ test "syntax query filtering preserves upstream colors" { } test "syntax Zig keyword captures cover both bytes beyond line ten thousand" { + if (comptime !minimal_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const code = "pub fn main() void {\n if (true) return;\n}\n"; @@ -1873,6 +1884,7 @@ test "syntax Zig keyword captures cover both bytes beyond line ten thousand" { } test "syntax allocator switching clears default-runtime caches" { + if (comptime !minimal_grammars) return error.SkipZigTest; const source = "fn main() void {}"; const initial = try highlightFileRange(std.testing.allocator, "a.zig", source, 0, source.len); std.testing.allocator.free(initial); @@ -1888,7 +1900,7 @@ test "syntax allocator switching clears default-runtime caches" { } test "syntax location context snapshots retain omitted multiline comment scope" { - if (!minimal_grammars) return; + if (!minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1914,6 +1926,7 @@ test "syntax location context snapshots retain omitted multiline comment scope" } test "syntax declaration locations clear snapshots without muting ordinary context" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -1933,7 +1946,7 @@ test "syntax declaration locations clear snapshots without muting ordinary conte } test "syntax stacked addresses do not split multiline source groups" { - if (!minimal_grammars) return; + if (!minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); @@ -2018,7 +2031,7 @@ test "syntax source analysis preserves declarations and injected colors" { } test "tables are the pipe_tables tree-sitter finds" { - if (!full_grammars) return; + if (!full_grammars) return error.SkipZigTest; start(std.testing.allocator); defer stop(); const Tables = @import("Tables.zig"); @@ -2087,6 +2100,7 @@ test "tables are the pipe_tables tree-sitter finds" { } test "a kept tree told its edits parses to the fresh parse's tree, places and all" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; const a = "const std = @import(\"std\");\n\nfn f(x: u32) u32 {\n return x;\n}\n\ntest \"t\" {\n _ = f(1);\n}\n"; const old_tree = parseTree("a.zig", a, null) orelse return error.NoTree; @@ -2126,6 +2140,7 @@ test "a kept tree told its edits parses to the fresh parse's tree, places and al } test "syntax: a grammar handed in at run time colours and walks as the one compiled in" { + if (comptime !minimal_grammars) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); diff --git a/docs/typ/building.typ b/docs/typ/building.typ index d4732fa9..1eb0f9b5 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -197,7 +197,6 @@ zig build kitty-test kitty graphics conformance of terminal panes, at the zig build kitty-harness kitty graphics through a pane end to end (a fake kitty terminal outside on the tui, the GPU capture on the gui; 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/consumer); unit-test runs it too |
