-
-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(format/grit): add tests for grit formatter #3937
Conversation
CodSpeed Performance ReportMerging #3937 will not alter performanceComparing Summary
|
crates/biome_service/Cargo.toml
Outdated
slotmap = { workspace = true, features = ["serde"] } | ||
tracing = { workspace = true, features = ["attributes", "log"] } | ||
biome_grit_syntax = { workspace = true } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the formatting changes might have been due to the newline here.
|
||
#[derive(Debug, Default, PartialEq, Eq)] | ||
|
||
pub(crate) struct GritFileHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that we're adding a file handler for Grit 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to hear! Haha. I've been following some of the other examples, and I've seen that we typically create a file handler struct as a part of the testing process.
Not sure if I'm doing too much work here, but it sounds like I'm working in the right direction!
As a side note, I'm a Rust newbie so any pointers on how I can improve my Rust code is welcome and appreciated :D
Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Note there does seem to be a test failure still. |
Hey @arendjr ! I see that test failure, and I'm currently working to resolve it. Thank you for the speedy review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for the tests to work, biome_service
needs to know how to handle the file. You'll need to add the language to the DocumentFileSource
enum. IIRC, can_parse
is the actual function that's used.
You should go ahead and add a experimental-grit
feature flag too, just like how html is set up. You can use #3967 for reference.
It looks like the codegen is failing and the tests are failing. To fix the codegen: |
Gotcha, thanks for the codegen stuff! I'm digging through the code a bit more now, and I think the test failures are due to me missing some additional configuration. I confirmed here that |
There was one more feature thing I forgot that will fix the tests: In biome_service = { workspace = true, features = ["experimental-grit"] } |
@dyc3 Thanks! That resolved the file handler issue. Still have some more errors, but these are related to differences in implementation. It looks like in the |
What’s the snapshot builder? In any case, I’m not entirely sure why I did it like that anymore… it might just have been an oversight 😅 |
@arendjr I was following the |
Ah, I see what you mean. I haven’t created formatter tests before, but it looks like that will be useful for formatter tests indeed. I hadn’t done that for the parser indeed, but those look a bit different anyway (I think I had based the parser tests on those for the CSS parser). |
@arendjr Yeah, I'm conflicted now. Because the parser tests I would imagine are different for a reason, so I'm debugging the issue I'm having with the snapshot builder Here's the exact line that is panicking Here's the error as well
|
Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
I’m not sure what caused the issue with that other test, but I might have a chance to look at it this week. If you like you can leave it in this PR in a disabled state, then I’ll follow up with a separate PR to enable it. |
I went ahead and fixed the merge conflict for you. |
@arendjr I figured out the issue with the test failure. I needed to run |
Summary
Add basic testing setup for the Grit formatter. Also added some additional configuration to handle Grit files.
Test Plan
Verify that tests for Grit execute successfully