-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
First step towards rustfix compiletest mode #50084
Conversation
r? @Manishearth |
I'd rather not have this a separate mode, and instead be a feature of UI tests themselves. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/tools/compiletest/Cargo.toml
Outdated
@@ -13,6 +13,7 @@ regex = "0.2" | |||
serde = "1.0" | |||
serde_json = "1.0" | |||
serde_derive = "1.0" | |||
rustfix = { git = "https://github.com/rust-lang-nursery/rustfix" } |
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.
We should publish before landing
src/tools/compiletest/src/autofix.rs
Outdated
let mut new_content = String::new(); | ||
|
||
// Add the lines before the section we want to replace | ||
new_content.push_str(&file_content |
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 feel like this API should be within rustfix itself, ideally shared with the rest of the code.
This also allocates once per suggestion.
Perhaps rustfix should have an API where it applies all suggestions in order, with a callback for asking for confirmation and stuff (which we pass as an empty callback here)
The purpose of this is both to test rustfix and the suggestions, so we need to use the same code as rustfix here.
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, absolutely. This is just the simplest code that works.
☔ The latest upstream changes (presumably #50056) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage @killercup ! Will you have time to address the review feedback soon? |
I'll have time to update this PR tomorrow (thank |
6c58c6a
to
57aa8d8
Compare
@alexcrichton asked how this PR and rustfix in general was doing. I was only able to make little progress here today. The PR is rebased and I moved the API for fixing suggestions to the rustfix crate (still unpublished, but that shouldn't be a blocker). Next immediate step is to add compiling of fixed files and asserting previously observed warnings are gone. After that, filtering of edition-critical lints. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
9bee46b
to
54e384f
Compare
Awesome thanks for the cc @killercup! I'm curious, though, would it perhaps be best to put tests into the rustfix crate itself? I'd imagine that'd allow for much faster iteration on rustfix itself. Or is the purpose here to test suggestions as they are added to rustc, using what's likely to be a relatively stable base in rustfix? I can try to clean up some of the todo items here tomorrow, I've had some experience in the past adding new rustfix modes and whatnot. |
Thanks! Ping me if you have any questions.
The latter: rustfix already has integration tests similar to compiletest
(incl. simple clippy support)—this is to make sure we can trust (and don’t
break) the suggestions rustc produces.
Alex Crichton <notifications@github.com> schrieb am Mi. 2. Mai 2018 um
01:38:
… Awesome thanks for the cc @killercup <https://github.com/killercup>!
I'm curious, though, would it perhaps be best to put tests into the
rustfix crate itself? I'd imagine that'd allow for much faster iteration on
rustfix itself. Or is the purpose here to test suggestions as they are
added to rustc, using what's likely to be a relatively stable base in
rustfix?
I can try to clean up some of the todo items here tomorrow, I've had some
experience in the past adding new rustfix modes and whatnot.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#50084 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABOX14NSJthUVOgO9ARF0Nuzr6D_e92ks5tuPHdgaJpZM4Tck8n>
.
|
9c4ffbf
to
4ea828b
Compare
Ok I've pushed up a commit that makes a dedicated suite for rustfix tests and populated with a set of working tests from I think the last step here is to publish rustfix to crates.io and get it pulled in from there. @killercup would it be possible to split out the binary/library to avoid having compiletest depend on dependencies like clap in this repo? |
Thanks so much, @alexcrichton! @Manishearth said in #50084 (comment) he'd rather see this is part of the UI tests, probably to speed the tests up and to see the regular diagnostics at the same time. |
@Manishearth can you elaborate on the idea for a UI mode? The implementation here with the necessary bells and whistles seems like it's pretty different from UI and somewhat makes sense as a separate mode? |
In general I see the process of testing such things to be the same as the process for testing things that need UI tests; i.e. if you're writing a fixture test you're probably also going to write a UI test. This also makes it easy to "upgrade" UI tests to fixture tests by adding a .fixed file, which hopefully will improve rustc suggestions overall. |
I think the "upgrade UI tests" workflow is pretty powerful: Ideally, we'd be able to make one PR soon that adds That said, it's not important right now: We only care about a handful of lints right now. |
Ok sounds good to me! I've folded this back into the UI test suite with the following implementation:
|
r? @Manishearth |
Thanks for working on this, @alexcrichton!
Why? Is this to trigger the "ensure the compiled code has no errors" thing? Would it make sense to add a Also: Can we rename |
60d78b4
to
e539c2b
Compare
@bors: r=Manishearth |
📌 Commit e539c2b has been approved by |
🔒 Merge conflict |
This is the first small step towards testing auto-fixable compiler suggestions using compiletest. Currently, it only checks if next to a UI test there also happens to a `*.rs.fixed` file, and then uses rustfix (added as external crate) on the original file, and asserts that it produces the fixed version. To show that this works, I've included one such test. I picked this test case at random (and because it was simple) -- It is not relevant to the 2018 edition. Indeed, in the near future, we want to be able to restrict rustfix to edition-lints, so this test cast might go away soon. In case you still think this is somewhat feature-complete, here's a quick list of things currently missing that I want to add before telling people they can use this: - [ ] Make this an actual compiletest mode, with `test [fix] …` output and everything - [ ] Assert that fixed files still compile - [ ] Assert that fixed files produce no (or a known set of) diagnostics output - [ ] Update `update-references.sh` to support rustfix - [ ] Use a published version of rustfix (i.e.: publish a new version rustfix that exposes a useful API for this)
Uses branch from <rust-lang/rustfix#63> until we publish a new release.
This commit adds a dedicated mode to compiletest for running rustfix tests, adding a new `src/test/rustfix` directory which will execute all tests as a "rustfix" test, namely requiring that a `*.fixed` is next to the main file which is the result of the rustfix project's application of fixes. The `rustfix` crate is pulled in to actually perform the fixing, and the rustfix compiletest mode will assert a few properties about the fixing: * The expected fixed output must be the same as rustc's output suggestions applied to the original code. * The fixed code must compile successfully * The fixed code must have no further diagnostics emitted about it
e539c2b
to
6f2d023
Compare
@bors: r=Manishearth |
📌 Commit 6f2d023 has been approved by |
First step towards rustfix compiletest mode This is the first small step towards testing auto-fixable compiler suggestions using compiletest. Currently, it only checks if next to a UI test there also happens to a `*.rs.fixed` file, and then uses rustfix (added as external crate) on the original file, and asserts that it produces the fixed version. To show that this works, I've included one such test. I picked this test case at random (and because it was simple) -- It is not relevant to the 2018 edition. Indeed, in the near future, we want to be able to restrict rustfix to edition-lints, so this test cast might go away soon. In case you still think this is somewhat feature-complete, here's a quick list of things currently missing that I want to add before telling people they can use this: - [x] Make this an actual compiletest mode, with `test [fix] …` output and everything - [x] Assert that fixed files still compile - [x] Assert that fixed files produce no (or a known set of) diagnostics output - [x] Update `update-references.sh` to support rustfix - [x] Use a published version of rustfix (i.e.: publish a new version rustfix that exposes a useful API for this)
☀️ Test successful - status-appveyor, status-travis |
…Simulacrum Remove vestigial rustfix tests. The directory `src/test/rustfix` is not actually tested. It looks like a mistake was made when rustfix tests were originally introduced in rust-lang#50084. In commit 6f2d023 they were moved to `src/test/ui`, but the tests in the original directory weren't deleted.
This is the first small step towards testing auto-fixable compiler
suggestions using compiletest. Currently, it only checks if next to a
UI test there also happens to a
*.rs.fixed
file, and then uses rustfix(added as external crate) on the original file, and asserts that it
produces the fixed version.
To show that this works, I've included one such test. I picked this test
case at random (and because it was simple) -- It is not relevant to the
2018 edition. Indeed, in the near future, we want to be able to restrict
rustfix to edition-lints, so this test cast might go away soon.
In case you still think this is somewhat feature-complete, here's a
quick list of things currently missing that I want to add before telling
people they can use this:
test [fix] …
outputand everything
output
update-references.sh
to support rustfixrustfix that exposes a useful API for this)