Skip to content

Commit 165ae93

Browse files
committed
test: lockfile path test for install
1 parent 3b17735 commit 165ae93

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

tests/testsuite/lockfile_path.rs

+46-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use snapbox::str;
77
use cargo_test_support::compare::assert_e2e;
88
use cargo_test_support::registry::{Package, RegistryBuilder};
99
use cargo_test_support::{
10-
basic_bin_manifest, cargo_test, project, symlink_supported, ProjectBuilder,
10+
basic_bin_manifest, cargo_process, cargo_test, project, symlink_supported, ProjectBuilder,
1111
};
1212

1313
///////////////////////////////
@@ -400,6 +400,51 @@ bar = "0.1.0"
400400
assert_e2e().eq(contents, lockfile_original);
401401
}
402402

403+
#[cargo_test]
404+
fn install_respects_lock_file_path() {
405+
// `cargo install` will imply --locked when lockfile path is provided
406+
Package::new("bar", "0.1.0").publish();
407+
Package::new("bar", "0.1.1")
408+
.file("src/lib.rs", "not rust")
409+
.publish();
410+
Package::new("foo", "0.1.0")
411+
.dep("bar", "0.1")
412+
.file("src/lib.rs", "")
413+
.file(
414+
"src/main.rs",
415+
"extern crate foo; extern crate bar; fn main() {}",
416+
)
417+
.file(
418+
"Cargo.lock",
419+
r#"
420+
[[package]]
421+
name = "bar"
422+
version = "0.1.0"
423+
source = "registry+https://github.com/rust-lang/crates.io-index"
424+
425+
[[package]]
426+
name = "foo"
427+
version = "0.1.0"
428+
dependencies = [
429+
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
430+
]
431+
"#,
432+
)
433+
.publish();
434+
435+
cargo_process("install foo")
436+
.with_stderr_data(str![[r#"
437+
...
438+
[..]not rust[..]
439+
...
440+
"#]])
441+
.with_status(101)
442+
.run();
443+
cargo_process("install foo -Zunstable-options --lockfile-path lockfile_dir/Cargo.lock")
444+
.masquerade_as_nightly_cargo(&["lockfile-path"])
445+
.run();
446+
}
447+
403448
#[cargo_test]
404449
fn run_embed() {
405450
let lockfile_path = "mylockfile/Cargo.lock";

0 commit comments

Comments
 (0)