-
Notifications
You must be signed in to change notification settings - Fork 657
Conversation
b659af6
to
70cbfb3
Compare
70cbfb3
to
066be64
Compare
Parser conformance results on ubuntu-latestT262
TS
|
console.log(import.meta); | ||
import.meta.field = | ||
obj.aReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariable; | ||
import.meta.aReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariable; | ||
## Output 2 |
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.
This is the new output
crates/rome_formatter/tests/specs/js/module/array/array_nested.js.snap
Outdated
Show resolved
Hide resolved
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.
6a74933
to
82d6fd4
Compare
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
pub struct SerializableFormatOptions { |
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.
The "remote derive" feature of serde might be useful for this (the facade types don't have to implement From
and TestOptions
can deserialize to FormatOptions
directly): https://serde.rs/remote-derive.html
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.
Thank you!
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.
@ematipico have you tried this?
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.
Yes, and it's not possible with the data structure that I want to have.
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.
Have you seen #2045 (comment)
But agree, this isn't important. I like the name SerializableFormatOptions
. It makes it clear what it is about.
afffd5c
to
293ebbc
Compare
I ended up going back to first solution I implemented:
|
Ah yes the #[derive(Serialize, Deserialize)]
#[serde(transparent)]
struct SerializableOptions(#[serde(with = "FormatOptionsDef")] FormatOptions); |
afa7437
to
1d11040
Compare
1d11040
to
0a57548
Compare
Other than some optimizations that can be done later on, the PR is ready and it implements what it supposed it. Can we merge it please? |
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
pub struct SerializableFormatOptions { |
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.
@ematipico have you tried this?
@@ -4,11 +4,11 @@ mod formatter { | |||
|
|||
mod js_module { | |||
use crate::spec_test; | |||
tests_macros::gen_tests! {"tests/specs/js/module/**/**/*.js", spec_test::run, "module"} | |||
tests_macros::gen_tests! {"tests/specs/js/module/**/**/**/*.js", spec_test::run, "module"} |
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.
This shouldn't be needed. **/*.js
should match all JS files regardless of the depth.
@@ -22,7 +103,7 @@ use std::path::Path; | |||
/// | |||
/// * `json/null` -> input: `tests/specs/json/null.json`, expected output: `tests/specs/json/null.json.snap` | |||
/// * `null` -> input: `tests/specs/null.json`, expected output: `tests/specs/null.json.snap` | |||
pub fn run(spec_input_file: &str, _: &str, file_type: &str) { | |||
pub fn run(spec_input_file: &str, _expected_file: &str, test_directory: &str, file_type: &str) { |
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.
Nit: The signature starts to become a bit awkward (so many strings). Could be worth having a SpecTestFile
struct that has different attributes like input_file
, expected_file
, and file_type
. I'm not sure what test_directory
is, whatever it belongs to the file or is the same for all files.
crates/tests_macros/src/lib.rs
Outdated
let mut ancestors = path.ancestors(); | ||
// the first one will yield the path to the current file | ||
ancestors.next(); | ||
let test_directory = ancestors.next().unwrap().display().to_string(); |
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.
What exactly is the test_directory
. Is it the parent directory of the file? Might be easier to understand if you call path.parent()
Summary
Closes #2044
Updated the test suite of the formatter. Now, it's possible to create test cases with a particular set of options by creating a
options.json
file beside the test file we want to test.All files inside a folder that contains
options.json
will be executed with the set of options written inside the file. Meaning that if you wanted to run only one particular file with some particular options, you would need to put the file inside a separate folder (the PR has an example).I slightly changed the output of the snapshot, that's why there are lot of changes.
Test Plan
Updated the current snapshots and create a new case with new output and verified that it is written.