Closed Ziqi-Yang closed 10 months ago
This script is nice to have 👌 I tested it and it works nicely.
I see several improvements:
git clone
)official/math/op/4
instead of official/math/op Test 4
tree-sitter test -f "official/" -u
on the generated testsMISSING
, EXPECTED
or ERROR
in the generated treesWhat do you think?
Yes, the improvements should be beneficial. And I also think more filtering is needed (and with the ability to automatically generate .gitignore
file). I'd like to give it a try later, to see whether the result is beneficial or on the other hand, increase the works we do.
After some more observation into the tests
directory of typst
repo. I believe I'm wrong. It is not a time-saving approach to directly use the official tests. While using official tests can improve the accuracy, it may greatly increase our workload. In accuracy part should be made up by the issues raised by community.
Verifying one by one the outputted trees is not on the table, because it is too long. But having this script able to detect ERROR
, MISSING
, or even if there is no segfault or whatever, is a really good thing.
Typst place their tests here
It should be mentioned that the tests is not specialized for syntax, whereas it contains many tests that are used for testing Typst compiler's output(i.e. syntax is correct, but result is wrong or error). However, if we use the official tests, we don't need to racking our brain to create many tests and we can 70%(IMO) make sure we get the correct syntax processing result, (if we totally manage our owns, with the tests growing larger, there may be some duplicates, though they can be properly managed if divided into a proper structure). What we need to do is to filter the tests that is suitable for our syntax testing, while ignoring others
How to do that? For example, this is an unsuitable test file (for testing computing):
We just ignore it. This is a suitable one:
We can append
Enabled
tag to the title of this test, and usetree-sitter test -f "Enabled"
to test those tests.I write a simple script to convert the official tests into tree sitter capable ones. By executing the following command, we can get the converted tests under
corpus/official
folder.If we have already created the
corpus/official
using this script, it will usegit diff <test directory>
andgit diff --name-only <test directory>
to get the diff and names of changed files between the latest commit of typst and the current one we are using for tests.