Skip to content

Commit 59b74f2

Browse files
committed
test: install without lockfile-path
- Showcase that install will require --locked and will put lockfile in a specific directory
1 parent d7bffc3 commit 59b74f2

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

tests/testsuite/lockfile_path.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ 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, paths, project, symlink_supported,
11+
ProjectBuilder,
1112
};
1213

1314
///////////////////////////////
@@ -400,6 +401,51 @@ bar = "0.1.0"
400401
assert_e2e().eq(contents, lockfile_original);
401402
}
402403

404+
#[cargo_test]
405+
fn install_without_lockfile_path() {
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 --locked").run();
444+
assert!(paths::root()
445+
.join("home/.cargo/registry/src/-ec6bec4300fe98b6/foo-0.1.0/Cargo.lock")
446+
.is_file());
447+
}
448+
403449
#[cargo_test]
404450
fn run_embed() {
405451
let lockfile_path = "mylockfile/Cargo.lock";

0 commit comments

Comments
 (0)