Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Oct 9, 2023
1 parent b48c41a commit 84c9359
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ enum Kind {
/// directive that we found in a lockfile, if present.
pub struct LockedPatchDependency {
/// The original `Dependency` directive, except "locked" so it's version
/// requirement is `=foo` and its `SourceId` has a "precise" listed.
/// requirement is Locked to `foo` and its `SourceId` has a "precise" listed.
pub dependency: Dependency,
/// The `PackageId` that was previously found in a lock file which
/// `dependency` matches.
Expand Down
51 changes: 51 additions & 0 deletions tests/testsuite/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3597,6 +3597,57 @@ fn differ_only_by_metadata() {
[CHECKING] baz v0.0.1+b
[CHECKING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
)
.run();

Package::new("baz", "0.0.1+d").publish();

p.cargo("clean").run();
p.cargo("check")
.with_stderr_contains("[CHECKING] baz v0.0.1+b")
.run();
}

#[cargo_test]
fn differ_only_by_metadata_with_lockfile() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
baz = "=0.0.1"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();

Package::new("baz", "0.0.1+a").publish();
Package::new("baz", "0.0.1+b").publish();
Package::new("baz", "0.0.1+c").publish();

p.cargo("update --package baz --precise 0.0.1+b")
.with_stderr(
"\
[UPDATING] [..] index
[..] baz v0.0.1+c -> v0.0.1+b
",
)
.run();

p.cargo("check")
.with_stderr(
"\
[DOWNLOADING] crates ...
[DOWNLOADED] [..] v0.0.1+b (registry `dummy-registry`)
[CHECKING] baz v0.0.1+b
[CHECKING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
)
.run();
Expand Down

0 comments on commit 84c9359

Please sign in to comment.