test command runs the test suite for a parser. It validates corpus tests, query validity, syntax highlighting tests, and tag tests.
t
Test Types
The command runs several types of tests:Corpus Tests
Located intest/corpus/, these tests verify that the parser produces the expected syntax trees for various inputs.
Query Tests
Validates that all queries in thequeries/ directory are syntactically correct and work with the parser.
Highlight Tests
Located intest/highlight/, these tests verify syntax highlighting produces expected results.
Tag Tests
Located intest/tags/, these tests verify symbol tagging produces expected tags.
Options
Test Selection
regex
Only run tests whose names match this regex.
regex
Skip tests whose names match this regex.
name
Only run tests from the given filename in the corpus.
Parser Options
path
The path to the directory containing the grammar. Implies
--rebuild.path
The path to the parser’s dynamic library. Used instead of the cached or automatically generated library.
string
If
--lib-path is used, the name of the language used to extract the library’s language function.Test Management
flag
Update the expected output of tests.
Output Options
flag
Only show the overview of test results, not the diff.
flag
Force showing fields in test diffs.
level
Show parsing statistics when tests are being run. One of:
all- Show statistics for every testoutliers-and-total- Show statistics only for outliers and totaltotal-only- Show only total statistics
flag
Output the test summary in a JSON format.
Debug Options
flag
Output parsing and lexing logs to stderr.
flag
Output logs of the graphs of the stack and parse trees. Graphs are constructed with graphviz dot, and output is written to
log.html.flag
When using
--debug-graph, open the log file in the default browser.flag
Compile the parser with debug flags enabled. Useful when debugging with
gdb or lldb.Build Options
flag
Compile and run the parser as a Wasm module (only if the CLI was built with
--features=wasm).flag
Force a rebuild of the parser before running tests.
path
The path to an alternative configuration (
config.json) file. See init-config.