Skip to content
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

Merged
merged 7 commits into from
Oct 4, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions tests/lockfile-compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use hamcrest::assert_that;
fn oldest_lockfile_still_works() {
Package::new("foo", "0.1.0").publish();

let expected_lock_file =
let expected_lockfile =
r#"[[package]]
name = "bar"
version = "0.0.1"
Expand All @@ -27,7 +27,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index"
"checksum foo 0.1.0 (registry+/~https://github.com/rust-lang/crates.io-index)" = "[..]"
"#;

let lockfile = r#"
let old_lockfile = r#"
[root]
name = "bar"
version = "0.0.1"
Expand All @@ -52,18 +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();
for (l, r) in expected_lock_file.lines().zip(lock.lines()) {
assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r);
}
for cargo_command in cargo_commands {
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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));

assert_eq!(lock.lines().count(), expected_lock_file.lines().count());
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]
Expand Down