Skip to main content
The test command runs the test suite for a parser. It validates corpus tests, query validity, syntax highlighting tests, and tag tests.
Aliases: t

Test Types

The command runs several types of tests:

Corpus Tests

Located in test/corpus/, these tests verify that the parser produces the expected syntax trees for various inputs.

Query Tests

Validates that all queries in the queries/ directory are syntactically correct and work with the parser.

Highlight Tests

Located in test/highlight/, these tests verify syntax highlighting produces expected results.

Tag Tests

Located in test/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.
Tests containing ERROR nodes or MISSING nodes will not be updated.

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 test
  • outliers-and-total - Show statistics only for outliers and total
  • total-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.

Examples

Run All Tests

Run Tests Matching a Pattern

Update Test Expectations

Run Tests with Statistics

Debug a Failing Test

Run Tests from Specific File

Show Only Overview