kentookura / tree-sitter-forester

tree-sitter grammar for forester
https://forester-tree-sitter-playground.netlify.app/
GNU General Public License v3.0
7 stars 2 forks source link

test: script for generating tests from real forester trees #13

Open jetjinser opened 1 month ago

jetjinser commented 1 month ago

I created a new forest trees to try my best to use all the syntax, and then I pulled Jon's public trees. I use git subtree to manage these trees. Then I wrote a script to generate tree-sitter tests from them.

Currently the script doesn't work due to a tree-sitter cli bug and I created a PR (https://github.com/tree-sitter/tree-sitter/pull/3590) for it.

I don't know how about this way of testing, this is just a POC, please give your suggestions.

kentookura commented 1 month ago

Hi, thanks for this work. I think the way to proceed is to write a github action that checks out the golden-forest repository on a push, rather than tracking these files: https://github.com/actions/checkout https://github.com/actions/checkout?tab=readme-ov-file#checkout-multiple-repos-side-by-side

jetjinser commented 1 month ago

My original purpose of putting these trees locally was to be able to test them locally. However, it also makes sense to test in CI, it's more convenient and doesn't have to deal with git subtree, I think I'll do it! It's just that I'd still like to be able to make local testing possible, any ideas?

By the way, the reason I created a separate golden-forest is to ensure that all trees can be successfully constructed by the forester.

kentookura commented 1 month ago

I think it is a good idea to have a separate forest for tests. I can make use of it in other projects as long as the example repo is up to date.

It's just that I'd still like to be able to make local testing possible, any ideas?

How about we add a script to this repository that clones the repo and runs the tests? Then we can still run the tests natively, and maybe even reuse that script in CI.

jetjinser commented 1 month ago

Sounds great!

You reminded me that this is what tree-sitter does, they have a script/fetch-fixtures to do it.

jetjinser commented 1 month ago

Hi, I just updated it, please take a look! @kentookura :)

kentookura commented 1 month ago

Overall this looks nice. I would like fix all errors that are reported by the tests before we merge this though, which will require us to update the grammar. If you'd like, you can open another PR with your changes to the grammar.