Commit graph

64 commits

Author SHA1 Message Date
WillLillis
577d333849 feat(cli): add test listing and allow users to parse a specific test number 2024-05-05 16:35:17 -04:00
Amaan Qureshi
33045ee898
fix(test): allow newlines in between test name and attribute 2024-05-05 15:19:42 -04:00
WillLillis
946acfd70f feat(cli): support NO_COLOR
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>

This allows users to avoid colored output when NO_COLOR is set to 1.
2024-04-29 20:25:41 -04:00
Amaan Qureshi
9ba8f6dfe6 fix(cli): test parsing on windows 2024-04-12 21:09:28 -04:00
Amaan Qureshi
abc7910381 refactor(rust): misc fixes & tidying 2024-04-11 22:35:43 -04:00
Amaan Qureshi
5825e24d56 style: wrap comments 2024-04-11 22:35:43 -04:00
Amaan Qureshi
b35efa8f33 style: format imports 2024-04-11 22:35:43 -04:00
Amaan Qureshi
0d2dea9e0e fix(test): allow colons in test names 2024-04-08 17:56:05 -04:00
ObserverOfTime
4b12eab927 feat(lib): implement Display for Node 2024-03-17 06:12:28 -04:00
Amaan Qureshi
5a4765ca01 style: clippy lints 2024-02-29 02:17:30 -05:00
Amaan Qureshi
8c4861c186 feat(test): add attributes for corpus tests 2024-02-29 02:17:30 -05:00
Amaan Qureshi
167855b289 fix(test): edge case when parsing UNEXPECTED/MISSING nodes with an indentation level greater than 0 2024-02-21 12:01:25 -05:00
Amaan Qureshi
a1a3903c10 fix(test): allow writing updates to tests without erroneous nodes instead of denying all of them if a single error is found 2024-02-21 12:01:25 -05:00
Amaan Qureshi
ef1b714e08 fix(cli): don't update tests automatically if parse errors are detected 2024-02-16 20:23:39 -05:00
Amaan Qureshi
e32a7f3998 chore: clippy lints 2024-02-16 16:32:07 -05:00
Amaan Qureshi
73f56bffa9 fix: sexp format edge case with quoted closed parenthesis 2024-02-13 18:31:28 -05:00
Amaan Qureshi
4149ed4149 chore: provide a CLI flag to open log.html
On macOS, this was done by default regardless of what the user wants.
This was also not done on Windows or Linux. Instead, we now provide a
`--open-log` flag to open the log file in the default browser, and it
works on all platforms.
2024-02-11 02:28:34 -05:00
buckynbrocko
8b38ab67de
chore(cli): reword test diff legend 2024-02-07 01:33:06 -05:00
buckynbrocko
a4a7edc5af
feat(cli): add include/exclude options to the test subcommand 2024-02-07 01:04:54 -05:00
dundargoc
c8bd6705cf
chore: clippy 2024-02-06 23:34:14 -05:00
Amaan Qureshi
f601c87091
fix: do not skip over spaces that are surrounded by quotes 2024-02-06 19:00:43 -05:00
Amaan Qureshi
04ff704bca
chore(cli): apply clippy fixes 2024-02-04 04:18:48 -05:00
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