-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Remove root from cargo lock #4571
Changes from 4 commits
850fbdc
008a126
6f03cce
f5fbf73
f5961e6
639bfb5
cab464e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -971,7 +971,7 @@ fn stale_cached_version() { | |
let rev = repo.revparse_single("HEAD").unwrap().id(); | ||
|
||
File::create(&foo.root().join("Cargo.lock")).unwrap().write_all(format!(r#" | ||
[root] | ||
[[package]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it true that changes in tests are mostly cosmetics? That is, the tests pass with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it. I made the same change against master branch and the test passes without a hitch |
||
name = "foo" | ||
version = "0.0.0" | ||
dependencies = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,24 @@ use hamcrest::assert_that; | |
fn oldest_lockfile_still_works() { | ||
Package::new("foo", "0.1.0").publish(); | ||
|
||
let lockfile = r#" | ||
let expected_lockfile = | ||
r#"[[package]] | ||
name = "bar" | ||
version = "0.0.1" | ||
dependencies = [ | ||
"foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
] | ||
|
||
[[package]] | ||
name = "foo" | ||
version = "0.1.0" | ||
source = "registry+https://github.com/rust-lang/crates.io-index" | ||
|
||
[metadata] | ||
"checksum foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "[..]" | ||
"#; | ||
|
||
let old_lockfile = r#" | ||
[root] | ||
name = "bar" | ||
version = "0.0.1" | ||
|
@@ -35,14 +52,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |
foo = "0.1.0" | ||
"#) | ||
.file("src/lib.rs", "") | ||
.file("Cargo.lock", lockfile); | ||
.file("Cargo.lock", old_lockfile); | ||
p.build(); | ||
|
||
assert_that(p.cargo("build"), | ||
execs().with_status(0)); | ||
let cargo_commands = vec![ | ||
"build", | ||
"update" | ||
]; | ||
|
||
let lock = p.read_lockfile(); | ||
assert!(lock.starts_with(lockfile.trim())); | ||
for cargo_command in cargo_commands { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I think this won't work as expected, because the second time around the lockfile will already be updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! of course. I'll probably create a helper method and loop through the vector. |
||
assert_that(p.cargo(cargo_command), | ||
execs().with_status(0)); | ||
|
||
let lock = p.read_lockfile(); | ||
for (l, r) in expected_lockfile.lines().zip(lock.lines()) { | ||
assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r); | ||
} | ||
|
||
assert_eq!(lock.lines().count(), expected_lockfile.lines().count()); | ||
} | ||
} | ||
|
||
#[test] | ||
|
@@ -61,7 +89,7 @@ fn totally_wild_checksums_works() { | |
"#) | ||
.file("src/lib.rs", "") | ||
.file("Cargo.lock", r#" | ||
[root] | ||
[[package]] | ||
name = "bar" | ||
version = "0.0.1" | ||
dependencies = [ | ||
|
@@ -85,7 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
||
let lock = p.read_lockfile(); | ||
assert!(lock.starts_with(r#" | ||
[root] | ||
[[package]] | ||
name = "bar" | ||
version = "0.0.1" | ||
dependencies = [ | ||
|
@@ -117,7 +145,7 @@ fn wrong_checksum_is_an_error() { | |
"#) | ||
.file("src/lib.rs", "") | ||
.file("Cargo.lock", r#" | ||
[root] | ||
[[package]] | ||
name = "bar" | ||
version = "0.0.1" | ||
dependencies = [ | ||
|
@@ -170,7 +198,7 @@ fn unlisted_checksum_is_bad_if_we_calculate() { | |
"#) | ||
.file("src/lib.rs", "") | ||
.file("Cargo.lock", r#" | ||
[root] | ||
[[package]] | ||
name = "bar" | ||
version = "0.0.1" | ||
dependencies = [ | ||
|
@@ -230,7 +258,7 @@ fn listed_checksum_bad_if_we_cannot_compute() { | |
"#, git.url())) | ||
.file("src/lib.rs", "") | ||
.file("Cargo.lock", &format!(r#" | ||
[root] | ||
[[package]] | ||
name = "bar" | ||
version = "0.0.1" | ||
dependencies = [ | ||
|
@@ -287,7 +315,7 @@ fn current_lockfile_format() { | |
let actual = p.read_lockfile(); | ||
|
||
let expected = "\ | ||
[root] | ||
[[package]] | ||
name = \"bar\" | ||
version = \"0.0.1\" | ||
dependencies = [ | ||
|
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.
Excellent catch! I haven't thought of the docs at all!