-
-
Notifications
You must be signed in to change notification settings - Fork 442
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
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #3937 will degrade performances by 7.05%Comparing Summary
Benchmarks breakdown
|
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
let root_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/specs/")); | ||
|
||
let Some(test_file) = SpecTestFile::try_from_file(spec_input_file, root_path, None) else { | ||
return; |
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 recommend panicking in this else branch, otherwise the test would fail silently. This happened in the html formatter recently.
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.
Looks like that uncovered a bug! Working to address it. Thanks!
Co-authored-by: Carson McManus <[email protected]>
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.
@dyc3 Perfect, thank you! I started going down that path and I was looking in |
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