Commit graph

42 commits

Author SHA1 Message Date
Max Brunsfeld
da16cb1459 Introduce language ref-count management C APIs, remove Copy impl for Language in Rust 2023-12-27 14:59:16 -08:00
Max Brunsfeld
3380e0eed7 Fix hang when printing dot graphs from the CLI 2023-10-31 15:59:37 -07:00
Max Brunsfeld
f4e2f68f14 Merge branch 'master' into wasm-language 2023-10-27 12:11:43 +01:00
Amaan Qureshi
ee399e67d4
fix: retain header and divider delimiter lengths when updating tests
This helps to prevent visual bloat in diffs when updating tests where the delimiter is not 80 chars long
2023-07-27 03:31:46 -04:00
Amaan Qureshi
36deb567c8
fix(tests): sort categories alphabetically 2023-07-24 03:05:09 -04:00
Max Brunsfeld
51720beeb0 Start work on a --wasm flag for the test subcommand 2022-11-15 17:14:33 -08:00
mliszcz
7bf2484d81 Fix test output formatting for rules starting with M/U
Previously the rule names could not begin with an uppercase M or U
because the test output formatter assumed that they represent special
tokens: MISSING or UEXPECTED.

Fixes #1940.
2022-11-15 20:20:44 +01:00
Max Brunsfeld
1d77b9ea47 cli: Fix parsing of test files with newlines in test names
Fixes #1527
2021-12-23 14:14:27 -08:00
Romanos Skiadas
4784ecaf0a fix crash on empty sexp in test, ()
Now this no longer crashes:

=====
a test
=====
-----
()

...

tree-sitter test:

1 failure:

expected / actual

  1. a test:

    (source_file)

    ()

fixes #1537
2021-12-15 19:10:26 +02:00
Max Brunsfeld
0e3a2780cd Avoid dynamic regex construction when parsing test files 2021-09-21 21:35:14 -07:00
Andrew Helwer
03b6a00bb8 Support for suffixes in test file separators
Some languages use the non-suffixed separators in their syntax
Fixes #982
2021-08-19 09:42:46 -04:00
Vladimir Panteleev
505bc5e1af
feat(cli): Make "test" output more readable 2021-07-19 10:56:21 +00:00
Douglas Creager
d2d01e77e3 cli: Use anyhow and thiserror for errors
This patch updates the CLI to use anyhow and thiserror for error
management.  The main feature that our custom `Error` type was providing
was a _list_ of messages, which would allow us to annotate "lower-level"
errors with more contextual information.  This is exactly what's
provided by anyhow's `Context` trait.

(This is setup work for a future PR that will pull the `config` and
`loader` modules out into separate crates; by using `anyhow` we wouldn't
have to deal with a circular dependency between with the new crates.)
2021-06-09 16:17:23 -04:00
Max Brunsfeld
7ebdebeafd
Merge pull request #871 from marcel0ll/master
Add ";" as comment in s-expressions
2021-03-11 09:24:50 -08:00
Patrick Thomson
44010d69ea Walk query files recursively in tree-sitter test.
We were only walking one level of depth into the `queries/` folder
during invocations of `test`, which made us attempt to open folders
rather than recurse into them.

We have to pull in the `walkdir` crate, which is required for
cross-platform walking of directories.

Fixes #938.
2021-02-25 10:24:54 -05:00
marceloll
057d299297 Allow comments only at line start 2021-01-08 13:28:40 -03:00
marceloll
0f5563c536 Add test for ; comments 2021-01-08 13:28:40 -03:00
marceloll
9500aff052 Use ; as comment in tests segxp section 2021-01-08 13:28:40 -03:00
Max Brunsfeld
96f259d8c5 Run rustfmt 2020-12-03 09:48:20 -08:00
Max Brunsfeld
026231e93d Merge branch 'master' into HEAD 2020-12-03 09:44:33 -08:00
Max Brunsfeld
518916f221 Return correct path and line in query errors from the CLI 2020-09-24 13:47:27 -07:00
Max Brunsfeld
49c632ae90 Fix error in test command when queries folder does not exist
Fixes #468
2019-10-21 09:22:24 -07:00
Max Brunsfeld
e14e285a10 cli: Check queries when running tree-sitter test 2019-10-18 14:44:16 -07:00
Ika
f191858bae fix: handle UNEXPECTED node 2019-10-03 21:24:17 +08:00
Ika
d88dae7a3e feat(cli): support snapshot testing with --update flag
This PR adds an `--update` flag to the `tree-sitter test` command, which adds the ability to replace the _expected_ output in the corpus.txt with the _actual_ output produced by the parser, that is, we can now simply use this `--update` flag to write all the corresponding parser output back to the corpus.txt, and we just need to check the output without typing its actual sexp.

- use the same output format as `tree-sitter parse`, except there won't be any position information printed.
- the corpus.txt won't be touched if there's no difference between the _expected_ output and the _actual_ output in that file.
- if there're differences between _expected_ and _actual_, _expected_ will be replaced by _actual_ and the whole file will be reformatted, i.e., all the output sexp will be formatted just like the output from `tree-sitter parse` and all the delimiters `===`/`---` will be normalized as 80-column long.
- this flag also works with `--filter` flag.
2019-09-06 10:57:59 +08:00
Max Brunsfeld
a8dedbee0d In test command, use the longest line of dashes as the test divider 2019-09-05 09:59:59 -07:00
Rob Donnelly
9ba5f25594 Ignore hidden files in grammar test directories (#430)
This fixes "stream did not contain valid UTF-8" error due to
`tree-sitter test` attempting to Vim's parse hidden binary swap files.
2019-08-19 09:03:12 -07:00
Max Brunsfeld
bd466febb4 highlight: Fix panic when cancelled before parsing a nested document 2019-07-16 14:34:24 -07:00
Max Brunsfeld
d274e81d0d Overhaul CLI error handling to allow multiple levels of context 2019-05-30 16:52:55 -07:00
Max Brunsfeld
65d1ce8593 lib: Include fields in ts_node_string output
This allows you to assert about fields in tests. But if your test 
s-expression does *not* include fields, the fields will be stripped from 
the regexp before comparison.
2019-02-13 09:47:21 -08:00
Max Brunsfeld
50281637d7 binding: Make parse methods more convenient
* Rename parse_str to parse and make it polymorphic.
* Rename parse_utf8 to parse_with, since it is now the callback-based
  version of parse
* Add a parse_utf16 method analogous to parse
* Rename existing parse_utf16 method to parse_utf16_with

This brings in the changes from tree-sitter/rust-tree-sitter#5
2019-02-05 10:59:33 -08:00
Max Brunsfeld
59f7511b1c Fix test command's exit code 2019-02-04 09:12:25 -08:00
Max Brunsfeld
4cac85fec4 Add benchmark script
* Structure `cli` crate as both a library and an executable, so that
benchmarks can import code from the crate.
* Import macros in the Rust 2018 style.
2019-02-01 15:17:35 -08:00
Max Brunsfeld
6d8ef48dad Make test subcommand exit 1 if tests fail 2019-01-27 09:53:49 -08:00
Max Brunsfeld
233d616ebf Add random mutation tests 2019-01-25 12:05:21 -08:00
Max Brunsfeld
3d11388cd1 Fix test subcommand bugs
* Log session was dropped before the parser
* Whitespace between close parens was not stripped
2019-01-17 12:40:21 -08:00
Max Brunsfeld
d8ab36b2a5 Fix bugs in handling tokens that overlap with separators 2019-01-15 13:21:48 -08:00
Max Brunsfeld
5c3c1dd0bd Get logging flags working properly with test script 2019-01-15 13:21:48 -08:00
Max Brunsfeld
0d85a1ef53 Exclude final newlines from inputs when parsing corpus files 2019-01-11 09:48:45 -08:00
Max Brunsfeld
98807d2053 Add debug and debug-graph flags to parse and test commands 2019-01-08 21:03:51 -08:00
Max Brunsfeld
6c4d00aad5 Print diffs when tests fail 2019-01-07 22:01:40 -08:00
Max Brunsfeld
8291d294fb Add test subcommand
Co-Authored-By: Timothy Clem <timothy.clem@gmail.com>
2019-01-07 17:57:27 -08:00