-
Notifications
You must be signed in to change notification settings - Fork 926
Make the JSON and checkstyle emitters work with stdin #3894
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
Conversation
…or other --emit values.
be defaulted depending on the mode.
I've added #[rustfmt::skip] to a couple of long lines; this would probably be better as test files rather than inline.
src/test/mod.rs
Outdated
init_log(); | ||
let input = "\nfn\n some( )\n{\n}\nfn main () {}\n"; | ||
#[rustfmt::skip] | ||
let output = r#"[{"name":"stdin","mismatches":[{"original_begin_line":1,"original_end_line":6,"expected_begin_line":1,"expected_end_line":2,"original":"\nfn\n some( )\n{\n}\nfn main () {}","expected":"fn some() {}\nfn main() {}"}]}]"#; |
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.
Re: your question on the other thread, some of the tests for these emitters are already leveraging a separate file with the json/xml/etc. output for the exp values.
For example:
Lines 216 to 222 in 9543838
#[test] | |
fn json_test() { | |
init_log(); | |
let filename = "tests/writemode/source/json.rs"; | |
let expected_filename = "tests/writemode/target/output.json"; | |
assert_output(Path::new(filename), Path::new(expected_filename)); | |
} |
Those files with the exp output reside in https://github.com/rust-lang/rustfmt/tree/master/tests/writemode/target
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.
Thanks - I've added an assert_stdin_output
which is similar and moved those ugly string literals into test files.
Closing in favor of #3896. |
This is further work on #3871.
The JSON and checkstyle emitters now work and are tested.
The tests have some very long string literals (the JSON and checkstyle output); I guess those would be better loading from files instead? I'm assuming
#[rustfmt::skip]
is frowned on in rustfmt.