From cab464eab79e62c8abbc95fce2f5faa8d07c0194 Mon Sep 17 00:00:00 2001 From: Ray Tung Date: Wed, 4 Oct 2017 01:57:49 +1100 Subject: [PATCH] Updated old lockfile tests --- tests/lockfile-compat.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/lockfile-compat.rs b/tests/lockfile-compat.rs index ffb3900da52..d9f6791687c 100644 --- a/tests/lockfile-compat.rs +++ b/tests/lockfile-compat.rs @@ -8,6 +8,16 @@ use hamcrest::assert_that; #[test] fn oldest_lockfile_still_works() { + let cargo_commands = vec![ + "build", + "update" + ]; + for cargo_command in cargo_commands { + oldest_lockfile_still_works_with_command(cargo_command); + } +} + +fn oldest_lockfile_still_works_with_command(cargo_command: &str) { Package::new("foo", "0.1.0").publish(); let expected_lockfile = @@ -53,24 +63,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "#) .file("src/lib.rs", "") .file("Cargo.lock", old_lockfile); - p.build(); - - let cargo_commands = vec![ - "build", - "update" - ]; - for cargo_command in cargo_commands { - assert_that(p.cargo(cargo_command), - execs().with_status(0)); + p.build(); - 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_that(p.cargo(cargo_command), + execs().with_status(0)); - assert_eq!(lock.lines().count(), expected_lockfile.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]