Skip to content

Commit

Permalink
test: lockfile path test for install
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifropc committed Sep 19, 2024
1 parent 3b17735 commit 165ae93
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion tests/testsuite/lockfile_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use snapbox::str;
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::registry::{Package, RegistryBuilder};
use cargo_test_support::{
basic_bin_manifest, cargo_test, project, symlink_supported, ProjectBuilder,
basic_bin_manifest, cargo_process, cargo_test, project, symlink_supported, ProjectBuilder,
};

///////////////////////////////
Expand Down Expand Up @@ -400,6 +400,51 @@ bar = "0.1.0"
assert_e2e().eq(contents, lockfile_original);
}

#[cargo_test]
fn install_respects_lock_file_path() {
// `cargo install` will imply --locked when lockfile path is provided
Package::new("bar", "0.1.0").publish();
Package::new("bar", "0.1.1")
.file("src/lib.rs", "not rust")
.publish();
Package::new("foo", "0.1.0")
.dep("bar", "0.1")
.file("src/lib.rs", "")
.file(
"src/main.rs",
"extern crate foo; extern crate bar; fn main() {}",
)
.file(
"Cargo.lock",
r#"
[[package]]
name = "bar"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "foo"
version = "0.1.0"
dependencies = [
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
"#,
)
.publish();

cargo_process("install foo")
.with_stderr_data(str![[r#"
...
[..]not rust[..]
...
"#]])
.with_status(101)
.run();
cargo_process("install foo -Zunstable-options --lockfile-path lockfile_dir/Cargo.lock")
.masquerade_as_nightly_cargo(&["lockfile-path"])
.run();
}

#[cargo_test]
fn run_embed() {
let lockfile_path = "mylockfile/Cargo.lock";
Expand Down

0 comments on commit 165ae93

Please sign in to comment.