Skip to content

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

Closed
wants to merge 14 commits into from

Conversation

jugglerchris
Copy link
Contributor

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.

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() {}"}]}]"#;
Copy link
Member

@calebcartwright calebcartwright Oct 27, 2019

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:

rustfmt/src/test/mod.rs

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

Copy link
Contributor Author

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.

@topecongiro
Copy link
Contributor

Closing in favor of #3896.

@topecongiro topecongiro closed this Nov 6, 2019
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.

3 participants