mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
fix: verify source before recompile
This fixes a regression introduced by #11407, which Cargo should always verify a source before it recompiles.
This commit is contained in:
parent
419a56f617
commit
98a73394f1
@ -391,9 +391,9 @@ pub fn prepare_target(cx: &mut Context<'_, '_>, unit: &Unit, force: bool) -> Car
|
||||
let compare = compare_old_fingerprint(&loc, &*fingerprint, mtime_on_use);
|
||||
log_compare(unit, &compare);
|
||||
|
||||
// If our comparison failed (e.g., we're going to trigger a rebuild of this
|
||||
// crate), then we also ensure the source of the crate passes all
|
||||
// verification checks before we build it.
|
||||
// If our comparison failed or reported dirty (e.g., we're going to trigger
|
||||
// a rebuild of this crate), then we also ensure the source of the crate
|
||||
// passes all verification checks before we build it.
|
||||
//
|
||||
// The `Source::verify` method is intended to allow sources to execute
|
||||
// pre-build checks to ensure that the relevant source code is all
|
||||
@ -401,7 +401,11 @@ pub fn prepare_target(cx: &mut Context<'_, '_>, unit: &Unit, force: bool) -> Car
|
||||
// directory sources which will use this hook to perform an integrity check
|
||||
// on all files in the source to ensure they haven't changed. If they have
|
||||
// changed then an error is issued.
|
||||
if compare.is_err() {
|
||||
if compare
|
||||
.as_ref()
|
||||
.map(|dirty| dirty.is_some())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let source_id = unit.pkg.package_id().source_id();
|
||||
let sources = bcx.packages.sources();
|
||||
let source = sources
|
||||
|
@ -2800,10 +2800,17 @@ fn verify_source_before_recompile() {
|
||||
//
|
||||
// Cargo should refuse to build because of checksum verfication failure.
|
||||
// Cargo shouldn't recompile dependency `bar`.
|
||||
// TODO: fix this wrong behaviour
|
||||
p.cargo("check --verbose")
|
||||
.env("RUSTFLAGS", "-W warnings")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[..]error: You shall not pass![..]")
|
||||
.with_stderr(
|
||||
"\
|
||||
error: the listed checksum of `[CWD]/vendor/bar/src/lib.rs` has changed:
|
||||
expected: [..]
|
||||
actual: [..]
|
||||
|
||||
directory sources are not [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user