summaryrefslogtreecommitdiff
path: root/core/syntax.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 16:12:55 -0300
committerGabriel Schneider <[email protected]>2026-11-20 16:38:40 -0300
commit06f6c72583faf8256190a0ae195a8085e7cd7f32 (patch)
tree4ceb3509121b23287f8f6e12b00726cb7535fca9 /core/syntax.zig
parenta2c5ad9cbd458693599831867b509a12b90ef99d (diff)
downloadpardes-06f6c72583faf8256190a0ae195a8085e7cd7f32.tar.gz
pardes-06f6c72583faf8256190a0ae195a8085e7cd7f32.zip
build: syntax-test deleted, and a test whose grammar is not built skips: the step rooted the syntax module at core/syntax.zig, where dev/Host.zig's `pardes.Surface` does not resolve (it no longer compiled), and every test it ran (syntax.zig's, named "syntax ...") already runs in core-test (core's test program 904 tests with and without a reference added: the same), so the step and its line in docs/typ/building.typ go; under -Dgrammars=none core-test failed to compile (a handed-grammar test names zig's queries) and then 16 tests failed or crashed, under minimal one (a JSON file's paint): each now returns error.SkipZigTest when the set it needs is not built (syntax.zig's own `if (!full_grammars) return;` passed silently, now skips too; minimal_grammars and full_grammars made pub for Query, Stream and File's tests); core-test: full 874/1031 (157 skipped), minimal 861/1031 (170 skipped), none 835/1031 (196 skipped), none failing; `zig build syntax` (the snapshots) builds and runs
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/syntax.zig')
-rw-r--r--core/syntax.zig47
1 files changed, 31 insertions, 16 deletions
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();