Fix fix::fix_in_dependency to not rely on rustc #13220
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changes the
fix::fix_in_dependency
test so that it does not rely on the behavior of rustc.This test is checking the behavior when rustc includes a suggestion diagnostic that modifies a file in CARGO_HOME from a dependency. rustc should not be emitting suggestions that point outside of the current crate, but there are some known bugs where it does this. #9938 added a workaround for this to avoid writing to CARGO_HOME.
However, the current test was relying on one of those bugs in rustc to exhibit its behavior. rust-lang/rust#119204 is fixing that particular behavior. Instead of relying on issues in rustc, this PR changes the test so that the test creates a fake
rustc
executable that will emit a hard-coded JSON message that tellscargo fix
to modify a file in CARGO_HOME. This should be stable as it is no longer relying on rustc.Testing or validating this change is a little tricky. You have to essentially comment out these three lines from the original #9938 change, and verify that the test fails (it says "Fixed" in the output). With those three lines in place, it should pass.