Skip to content

Conversation

@bew
Copy link
Contributor

@bew bew commented Apr 24, 2025

Closes #176

I tried to add tests but have hit a few roadblocks:

  1. When I try to run the tests (for all langs or just for terraform) the test runner seems to hang after outputing a few Scheduling: path/to/..._spec.lua lines (I tried on MacOS for now)
  2. I don't understand the result data field 🤔
    (also, shouldn't expected be { 3, 7 } for data_for_split in the example?)

@Wansmer
Copy link
Owner

Wansmer commented Apr 25, 2025

expected - numbers of rows with the reference version of the node in the desired state for further comparison. result - numbers of rows after execution of the function under test (split/join), i.e. lines that the node will occupy after formatting.
See how tests for any other language are made in the tests directory.

When I try to run the tests (for all langs or just for terraform) the test runner seems to hang after outputing a few Scheduling: path/to/..._spec.lua lines (I tried on MacOS for now)

Try call make preinstall-ts-parsers before run tests

@bew
Copy link
Contributor Author

bew commented Apr 25, 2025

When I try to run the tests (for all langs or just for terraform) the test runner seems to hang after outputing a few Scheduling: path/to/..._spec.lua lines (I tried on MacOS for now)

Try call make preinstall-ts-parsers before run tests

Yes sorry should have mentioned, here is a screenshot of what I see..
image
I tried waiting for the tests to start, but it seems it auto-stopped after 50sec 🤔


See how tests for any other language are made in the tests directory.

Well I tried to understand some simple ones like the Nix ones but I was still lost..

I actually finally understood what was going on by looking at the tu._test_format function.. 😅
Making all the tests now, I'm using this field mapping in my head:

  • result_range for result
  • compare_to_range for expected

and flipping the order of result and expected in the test data, because it reads better to me like text in result_range should equal text in compare_to_range.
(if you're interested into different names/wording ¯\_(ツ)_/¯)

@bew
Copy link
Contributor Author

bew commented Apr 26, 2025

Wasn't able to run the tests locally, but from my understanding the test data should be okay 🤔

@bew bew marked this pull request as ready for review April 26, 2025 00:03
@Wansmer
Copy link
Owner

Wansmer commented Apr 26, 2025

I've fixed the tests. It's strange that they didn't run locally. I'm using macos too - everything works.
Thanks for the PR!

@Wansmer Wansmer merged commit 19af129 into Wansmer:main Apr 26, 2025
2 checks passed
@bew bew deleted the add-terraform branch April 26, 2025 08:04
@bew
Copy link
Contributor Author

bew commented Apr 26, 2025

Ah I missed the 0-based rows ^^'
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Terraform

2 participants