-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Integrate rustfix into clippy test suite #2376
Comments
I originally thought about integrating this into compiletest (which already compiles the files and reads the compiler's JSON output). This is a pretty unique case, though: It's only useful to test the applied suggestions when you write lints. I'll most likely have time to work on this on Saturday. Ping me and we can work on this together :) |
The only issue I see with the way That said, compiletest is a total mess imo. It keeps breaking if you don't I once tried simply removing ui tests and using a crate that has a file in the For now we can just keep the ui tests for everything that needs non-std dependencies and move everything else to rustfix tests |
Oh we also need to publish rustfix in order to be able to have clippy depend on it. Out of some reason even |
If we want to depend on it directly, sure. Moving all the relevant rustfix code to the clippy repo is also a valid option IMHO. Which features of compiletest is clippy using? Just the UI tests by now, or also the Which dependencies are clippy's test using? FTR, the The |
Rustc will want that at some point, too
just the ui tests
serde, regex, rustc, alloc, core,
👍 best reason |
Actually, I'd prefer to run this regardless of the existence of a fixtures file. Or, perhaps, as a first pass, we can just focus on having it compile. Have a whitelist of tests we wish to rustfix, and slowly grow that till the suite is covered. Ensure they all compile without errors post-rustfix. Then, change the test so that much like update-all-references the generated rs files get cached in the build dir, and we have tooling to update files under fixtures/ . |
Cool, we could easily make two runs based on the same structure (in parallel on CI even), one testing the human readable output, and one for rustfix.
@Manishearth, the current Ideally, we could also have a tidy script that makes sure that for lints that have a |
the json output contains the human readable output. Just concatenate all of them, no need to build twice ;) |
Starting to work on rust-lang#2376, this annotation got in the way. Going to remove it for now.
Integrate rustfix into Clippy test suite Once the [PR to compiletest-rs](Manishearth/compiletest-rs#151) is reviewed and merged this fixes #2376. I will create a separate tracking issue for adding `run-rustfix` to all tests.
Let's test the suggestions clippy generates! (I talked about this with various people from time to time, but never opened an issue here for discussion.)
Recently, I refactored rustfix' test suite to basically not test the rustfix CLI but the suggestions and their fixes. You can find the test code here. It's pretty self-contained and only uses rustfix to get the suggestion from the compiler (but contains code to apply them). Indeed, the rustfix code base is very small and basically only a shim around parsing the compiler's json output and extracting suggestions. So in theory, I could easily make this a single test file (i.e., without dependencies on the rustfix repo) that you add as a job to clippy's CI.
The same test procedure would work very well with clippy's UI tests: If there is a
foo.fixed.rs
next tofoo.rs
, the test will apply rustfix tofoo.rs
and assert that it generatesfoo.fixed.rs
(and thatfoo.fixed.rs
compiles!). This would be a great way to ensure that clippy generates sensible suggestions, document edge cases, and also be a good starting point to specify which suggestions are auto-applicable (cf. https://github.com/killercup/rustfix/pull/44#issuecomment-357920563, rust-lang/rust#39254).The text was updated successfully, but these errors were encountered: