From 4b00353a3315b8961f92fefd158371c24689b948 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:20:18 -0600 Subject: [PATCH 01/11] test(lockfile): Remove test headers --- tests/testsuite/lockfile_path.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index 9d5d453e606..d0c3e2d1bef 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -12,9 +12,6 @@ use cargo_test_support::registry::{Package, RegistryBuilder}; use cargo_test_support::{ ProjectBuilder, basic_bin_manifest, cargo_test, paths, project, symlink_supported, }; -/////////////////////////////// -//// Unstable feature tests start -/////////////////////////////// #[cargo_test] fn must_have_unstable_options() { @@ -52,10 +49,6 @@ See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more inform .run(); } -/////////////////////////////// -//// Unstable feature tests end -/////////////////////////////// - #[cargo_test] fn basic_lockfile_created() { let lockfile_path = "mylockfile/is/burried/Cargo.lock"; @@ -104,10 +97,6 @@ fn basic_lockfile_override() { assert!(p.root().join(lockfile_path).is_file()); } -////////////////////// -///// Symlink tests -////////////////////// - #[cargo_test] fn symlink_in_path() { if !symlink_supported() { @@ -220,10 +209,6 @@ fn loop_symlink() { .run(); } -///////////////////////// -//// Commands tests -///////////////////////// - #[cargo_test] fn add_lockfile_override() { let lockfile_path = "mylockfile/Cargo.lock"; From 0c3dba473e00fef3a5ca190767a38b4711815465 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:21:56 -0600 Subject: [PATCH 02/11] test(lockfile): Put config tests first --- tests/testsuite/lockfile_path.rs | 142 +++++++++++++++---------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index d0c3e2d1bef..ae40089af9e 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -13,6 +13,77 @@ use cargo_test_support::{ ProjectBuilder, basic_bin_manifest, cargo_test, paths, project, symlink_supported, }; +#[cargo_test] +fn config_lockfile_path_without_z_flag() { + let p = make_project().build(); + + p.cargo("generate-lockfile") + .arg("--config") + .arg("resolver.lockfile-path='my/Cargo.lock'") + .with_stderr_data(str![[r#" +[WARNING] ignoring `resolver.lockfile-path`, pass `-Zlockfile-path` to enable it + +"#]]) + .run(); + + assert!(p.root().join("Cargo.lock").exists()); + assert!(!p.root().join("my/Cargo.lock").exists()); +} + +#[cargo_test] +fn config_lockfile_path() { + let p = make_project().build(); + + p.cargo("generate-lockfile -Zlockfile-path") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("--config") + .arg("resolver.lockfile-path='my/Cargo.lock'") + .with_stderr_data(str![""]) + .run(); + + assert!(!p.root().join("Cargo.lock").exists()); + assert!(p.root().join("my/Cargo.lock").exists()); +} + +#[cargo_test] +fn cli_ignored_when_config_set() { + let cli_lockfile_path = "cli/Cargo.lock"; + let p = make_project().build(); + + p.cargo("generate-lockfile -Zlockfile-path") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("--config") + .arg("resolver.lockfile-path='my/Cargo.lock'") + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(cli_lockfile_path) + .with_stderr_data(str![[r#" +[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead +[WARNING] `--lockfile-path` is ignored because `resolver.lockfile-path` is set in config + +"#]]) + .run(); + + assert!(p.root().join("my/Cargo.lock").is_file()); + assert!(!p.root().join(cli_lockfile_path).exists()); +} + +#[cargo_test] +fn config_lockfile_path_rejects_templates() { + let p = make_project().build(); + + p.cargo("generate-lockfile -Zlockfile-path") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("--config") + .arg("resolver.lockfile-path='{var}/Cargo.lock'") + .with_status(101) + .with_stderr_data(str![[r#" +[ERROR] unexpected variable `var` in resolver.lockfile-path `{var}/Cargo.lock` + +"#]]) + .run(); +} + #[cargo_test] fn must_have_unstable_options() { let lockfile_path = "mylockfile/is/burried/Cargo.lock"; @@ -518,77 +589,6 @@ fn run_embed() { .run(); } -#[cargo_test] -fn config_lockfile_path() { - let p = make_project().build(); - - p.cargo("generate-lockfile -Zlockfile-path") - .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("--config") - .arg("resolver.lockfile-path='my/Cargo.lock'") - .with_stderr_data(str![""]) - .run(); - - assert!(!p.root().join("Cargo.lock").exists()); - assert!(p.root().join("my/Cargo.lock").exists()); -} - -#[cargo_test] -fn cli_ignored_when_config_set() { - let cli_lockfile_path = "cli/Cargo.lock"; - let p = make_project().build(); - - p.cargo("generate-lockfile -Zlockfile-path") - .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("--config") - .arg("resolver.lockfile-path='my/Cargo.lock'") - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(cli_lockfile_path) - .with_stderr_data(str![[r#" -[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead -[WARNING] `--lockfile-path` is ignored because `resolver.lockfile-path` is set in config - -"#]]) - .run(); - - assert!(p.root().join("my/Cargo.lock").is_file()); - assert!(!p.root().join(cli_lockfile_path).exists()); -} - -#[cargo_test] -fn config_lockfile_path_without_z_flag() { - let p = make_project().build(); - - p.cargo("generate-lockfile") - .arg("--config") - .arg("resolver.lockfile-path='my/Cargo.lock'") - .with_stderr_data(str![[r#" -[WARNING] ignoring `resolver.lockfile-path`, pass `-Zlockfile-path` to enable it - -"#]]) - .run(); - - assert!(p.root().join("Cargo.lock").exists()); - assert!(!p.root().join("my/Cargo.lock").exists()); -} - -#[cargo_test] -fn config_lockfile_path_rejects_templates() { - let p = make_project().build(); - - p.cargo("generate-lockfile -Zlockfile-path") - .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("--config") - .arg("resolver.lockfile-path='{var}/Cargo.lock'") - .with_status(101) - .with_stderr_data(str![[r#" -[ERROR] unexpected variable `var` in resolver.lockfile-path `{var}/Cargo.lock` - -"#]]) - .run(); -} - const VALID_LOCKFILE: &str = r#"# Test lockfile version = 4 From 9da81c9c26fb47098497342fdf0cfccaca53d05c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:27:19 -0600 Subject: [PATCH 03/11] test(lockfile): Pull out path to custom lockfile --- tests/testsuite/lockfile_path.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index ae40089af9e..ca29c348153 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -32,28 +32,30 @@ fn config_lockfile_path_without_z_flag() { #[cargo_test] fn config_lockfile_path() { + let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project().build(); p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("--config") - .arg("resolver.lockfile-path='my/Cargo.lock'") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .with_stderr_data(str![""]) .run(); assert!(!p.root().join("Cargo.lock").exists()); - assert!(p.root().join("my/Cargo.lock").exists()); + assert!(p.root().join(lockfile_path).exists()); } #[cargo_test] fn cli_ignored_when_config_set() { + let lockfile_path = "mylockfile/Cargo.lock"; let cli_lockfile_path = "cli/Cargo.lock"; let p = make_project().build(); p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("--config") - .arg("resolver.lockfile-path='my/Cargo.lock'") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .arg("-Zunstable-options") .arg("--lockfile-path") .arg(cli_lockfile_path) @@ -64,7 +66,7 @@ fn cli_ignored_when_config_set() { "#]]) .run(); - assert!(p.root().join("my/Cargo.lock").is_file()); + assert!(p.root().join(lockfile_path).exists()); assert!(!p.root().join(cli_lockfile_path).exists()); } From 94c3ae9caf3564fa94997132a89f51fd5f7b1f2a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:30:13 -0600 Subject: [PATCH 04/11] test(lockfile): Clarify which tests are focusing on the CLI --- tests/testsuite/lockfile_path.rs | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index ca29c348153..a8563e4abbc 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -87,7 +87,7 @@ fn config_lockfile_path_rejects_templates() { } #[cargo_test] -fn must_have_unstable_options() { +fn cli_must_have_unstable_options() { let lockfile_path = "mylockfile/is/burried/Cargo.lock"; let p = make_project().build(); @@ -105,7 +105,7 @@ See https://github.com/rust-lang/cargo/issues/14421 for more information about t } #[cargo_test] -fn must_be_nightly() { +fn cli_must_be_nightly() { let lockfile_path = "mylockfile/is/burried/Cargo.lock"; let p = make_project().build(); @@ -123,7 +123,7 @@ See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more inform } #[cargo_test] -fn basic_lockfile_created() { +fn cli_basic_lockfile_created() { let lockfile_path = "mylockfile/is/burried/Cargo.lock"; let p = make_project().build(); @@ -138,7 +138,7 @@ fn basic_lockfile_created() { } #[cargo_test] -fn basic_lockfile_read() { +fn cli_basic_lockfile_read() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project().file(lockfile_path, VALID_LOCKFILE).build(); @@ -154,7 +154,7 @@ fn basic_lockfile_read() { } #[cargo_test] -fn basic_lockfile_override() { +fn cli_basic_lockfile_override() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project() .file("Cargo.lock", "This is an invalid lock file!") @@ -171,7 +171,7 @@ fn basic_lockfile_override() { } #[cargo_test] -fn symlink_in_path() { +fn cli_symlink_in_path() { if !symlink_supported() { return; } @@ -197,7 +197,7 @@ fn symlink_in_path() { } #[cargo_test] -fn symlink_lockfile() { +fn cli_symlink_lockfile() { if !symlink_supported() { return; } @@ -224,7 +224,7 @@ fn symlink_lockfile() { } #[cargo_test] -fn broken_symlink() { +fn cli_broken_symlink() { if !symlink_supported() { return; } @@ -252,7 +252,7 @@ fn broken_symlink() { } #[cargo_test] -fn loop_symlink() { +fn cli_loop_symlink() { if !symlink_supported() { return; } @@ -283,7 +283,7 @@ fn loop_symlink() { } #[cargo_test] -fn add_lockfile_override() { +fn cli_add_lockfile_override() { let lockfile_path = "mylockfile/Cargo.lock"; project() .at("bar") @@ -306,7 +306,7 @@ fn add_lockfile_override() { } #[cargo_test] -fn clean_lockfile_override() { +fn cli_clean_lockfile_override() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project() .file("Cargo.lock", "This is an invalid lock file!") @@ -324,7 +324,7 @@ fn clean_lockfile_override() { } #[cargo_test] -fn fix_lockfile_override() { +fn cli_fix_lockfile_override() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project() .file("Cargo.lock", "This is an invalid lock file!") @@ -343,7 +343,7 @@ fn fix_lockfile_override() { } #[cargo_test] -fn publish_lockfile_read() { +fn cli_publish_lockfile_read() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project().file(lockfile_path, VALID_LOCKFILE).build(); let registry = RegistryBuilder::new().http_api().http_index().build(); @@ -361,7 +361,7 @@ fn publish_lockfile_read() { } #[cargo_test] -fn remove_lockfile_override() { +fn cli_remove_lockfile_override() { let lockfile_path = "mylockfile/Cargo.lock"; let manifest = r#" [package] @@ -402,7 +402,7 @@ fn remove_lockfile_override() { } #[cargo_test] -fn assert_respect_pinned_version_from_lockfile_path() { +fn cli_assert_respect_pinned_version_from_lockfile_path() { let lockfile_path = "mylockfile/Cargo.lock"; let p = project() .file( @@ -460,7 +460,7 @@ bar = "0.1.0" } #[cargo_test] -fn install_respects_lock_file_path() { +fn cli_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") @@ -529,7 +529,7 @@ dependencies = [ } #[cargo_test] -fn install_lock_file_path_must_present() { +fn cli_install_lock_file_path_must_present() { // `cargo install` will imply --locked when lockfile path is provided Package::new("bar", "0.1.0").publish(); Package::new("foo", "0.1.0") @@ -553,7 +553,7 @@ fn install_lock_file_path_must_present() { } #[cargo_test(nightly, reason = "-Zscript is unstable")] -fn run_embed() { +fn cli_run_embed() { let lockfile_path = "mylockfile/Cargo.lock"; let invalid_lockfile = "Cargo.lock"; let p = project() From a87ba83246c4472538fc2e4a8ef074bc7b3fdeec Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:30:38 -0600 Subject: [PATCH 05/11] test(lockfile): Highlight parallel between CLI and config --- tests/testsuite/lockfile_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index a8563e4abbc..8ac9f9c8679 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -31,7 +31,7 @@ fn config_lockfile_path_without_z_flag() { } #[cargo_test] -fn config_lockfile_path() { +fn config_lockfile_created() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project().build(); From 9ead80e3179ca5bb2a7ca375100b65c21394bfc0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:32:06 -0600 Subject: [PATCH 06/11] test(lockfile): Fork CLI tests to turn into Config tests --- tests/testsuite/lockfile_path.rs | 454 +++++++++++++++++++++++++++++++ 1 file changed, 454 insertions(+) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index 8ac9f9c8679..d4ca85112e3 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -46,6 +46,460 @@ fn config_lockfile_created() { assert!(p.root().join(lockfile_path).exists()); } +#[cargo_test] +fn config_basic_lockfile_read() { + let lockfile_path = "mylockfile/Cargo.lock"; + let p = make_project().file(lockfile_path, VALID_LOCKFILE).build(); + + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .run(); + + assert!(!p.root().join("Cargo.lock").exists()); + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_basic_lockfile_override() { + let lockfile_path = "mylockfile/Cargo.lock"; + let p = make_project() + .file("Cargo.lock", "This is an invalid lock file!") + .build(); + + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .run(); + + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_symlink_in_path() { + if !symlink_supported() { + return; + } + + let dst = "dst"; + let src = "somedir/link"; + let lockfile_path = format!("{src}/Cargo.lock"); + + let p = make_project().symlink_dir(dst, src).build(); + + fs::create_dir(p.root().join("dst")).unwrap(); + assert!(p.root().join(src).is_dir()); + + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path.as_str()) + .run(); + + assert!(p.root().join(lockfile_path).is_file()); + assert!(p.root().join(dst).join("Cargo.lock").is_file()); +} + +#[cargo_test] +fn config_symlink_lockfile() { + if !symlink_supported() { + return; + } + + let lockfile_path = "dst/Cargo.lock"; + let src = "somedir/link"; + let lock_body = VALID_LOCKFILE; + + let p = make_project() + .file(lockfile_path, lock_body) + .symlink(lockfile_path, src) + .build(); + + assert!(p.root().join(src).is_file()); + + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .run(); + + assert!(!p.root().join("Cargo.lock").exists()); +} + +#[cargo_test] +fn config_broken_symlink() { + if !symlink_supported() { + return; + } + + let invalid_dst = "invalid_path"; + let src = "somedir/link"; + let lockfile_path = format!("{src}/Cargo.lock"); + + let p = make_project().symlink_dir(invalid_dst, src).build(); + assert!(!p.root().join(src).is_dir()); + + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .with_status(101) + .with_stderr_data(str![[r#" +[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead +[ERROR] failed to create directory `[ROOT]/foo/somedir/link` +... + +"#]]) + .run(); +} + +#[cargo_test] +fn config_loop_symlink() { + if !symlink_supported() { + return; + } + + let loop_link = "loop"; + let src = "somedir/link"; + let lockfile_path = format!("{src}/Cargo.lock"); + + let p = make_project() + .symlink_dir(loop_link, src) + .symlink_dir(src, loop_link) + .build(); + assert!(!p.root().join(src).is_dir()); + + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .with_status(101) + .with_stderr_data(str![[r#" +[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead +[ERROR] failed to create directory `[ROOT]/foo/somedir/link` +... + +"#]]) + .run(); +} + +#[cargo_test] +fn config_add_lockfile_override() { + let lockfile_path = "mylockfile/Cargo.lock"; + project() + .at("bar") + .file("Cargo.toml", LIB_TOML) + .file("src/main.rs", "fn main() {}") + .build(); + let p = make_project() + .file("Cargo.lock", "This is an invalid lock file!") + .build(); + p.cargo("add") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .arg("--path") + .arg("../bar") + .run(); + + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_clean_lockfile_override() { + let lockfile_path = "mylockfile/Cargo.lock"; + let p = make_project() + .file("Cargo.lock", "This is an invalid lock file!") + .build(); + p.cargo("clean") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .arg("--package") + .arg("test_foo") + .run(); + + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_fix_lockfile_override() { + let lockfile_path = "mylockfile/Cargo.lock"; + let p = make_project() + .file("Cargo.lock", "This is an invalid lock file!") + .build(); + p.cargo("fix") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .arg("--package") + .arg("test_foo") + .arg("--allow-no-vcs") + .run(); + + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_publish_lockfile_read() { + let lockfile_path = "mylockfile/Cargo.lock"; + let p = make_project().file(lockfile_path, VALID_LOCKFILE).build(); + let registry = RegistryBuilder::new().http_api().http_index().build(); + + p.cargo("publish") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .replace_crates_io(registry.index_url()) + .run(); + + assert!(!p.root().join("Cargo.lock").exists()); + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_remove_lockfile_override() { + let lockfile_path = "mylockfile/Cargo.lock"; + let manifest = r#" + [package] + + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + edition = "2015" + + [[bin]] + + name = "foo" + + [dependencies] + test_bar = { version = "0.1.0", path = "../bar" } + "#; + + project() + .at("bar") + .file("Cargo.toml", LIB_TOML) + .file("src/main.rs", "fn main() {}") + .build(); + + let p = project() + .file("Cargo.toml", &manifest) + .file("src/main.rs", "fn main() {}") + .file("Cargo.lock", "This is an invalid lock file!") + .build(); + p.cargo("remove") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .arg("test_bar") + .run(); + + assert!(p.root().join(lockfile_path).is_file()); +} + +#[cargo_test] +fn config_assert_respect_pinned_version_from_lockfile_path() { + let lockfile_path = "mylockfile/Cargo.lock"; + let p = project() + .file( + "Cargo.toml", + r#"# +[package] + +name = "test_foo" +version = "0.5.0" +authors = ["wycats@example.com"] +edition = "2015" + +[[bin]] + +name = "test_foo" + +[dependencies] +bar = "0.1.0" +"#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + Package::new("bar", "0.1.0").publish(); + p.cargo("generate-lockfile") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .run(); + + assert!(!p.root().join("Cargo.lock").exists()); + assert!(p.root().join(lockfile_path).is_file()); + + let lockfile_original = fs::read_to_string(p.root().join(lockfile_path)).unwrap(); + + Package::new("bar", "0.1.1").publish(); + p.cargo("package") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("--lockfile-path") + .arg(lockfile_path) + .run(); + + assert!( + p.root() + .join("target/package/test_foo-0.5.0/Cargo.lock") + .is_file() + ); + + let path = p.root().join("target/package/test_foo-0.5.0/Cargo.lock"); + let contents = fs::read_to_string(path).unwrap(); + + assert_e2e().eq(contents, lockfile_original); +} + +#[cargo_test] +fn config_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(); + // Publish with lockfile containing bad version of `bar` (0.1.1) + 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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "foo" +version = "0.1.0" +dependencies = [ + "bar 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] +"#, + ) + .publish(); + + cargo_process("install foo --locked") + .with_stderr_data(str![[r#" +... +[..]not rust[..] +... +"#]]) + .with_status(101) + .run(); + + // Create lockfile with the good `bar` version (0.1.0) and use it for install + project() + .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)", +] +"#, + ) + .build(); + cargo_process("install foo -Zunstable-options --lockfile-path foo/Cargo.lock") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .run(); + + assert!(paths::root().join("foo/Cargo.lock").is_file()); + assert_has_installed_exe(paths::cargo_home(), "foo"); +} + +#[cargo_test] +fn config_install_lock_file_path_must_present() { + // `cargo install` will imply --locked when lockfile path is provided + Package::new("bar", "0.1.0").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() {}", + ) + .publish(); + + cargo_process("install foo -Zunstable-options --lockfile-path lockfile_dir/Cargo.lock") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .with_stderr_data(str![[r#" +... +[ERROR] no Cargo.lock file found in the requested path [ROOT]/lockfile_dir/Cargo.lock +... +"#]]) + .with_status(101) + .run(); +} + +#[cargo_test(nightly, reason = "-Zscript is unstable")] +fn config_run_embed() { + let lockfile_path = "mylockfile/Cargo.lock"; + let invalid_lockfile = "Cargo.lock"; + let p = project() + .file("src/main.rs", "fn main() {}") + .file("Cargo.lock", "This is an invalid lock file!") + .build(); + + p.cargo("run") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("-Zscript") + .arg("--lockfile-path") + .arg(lockfile_path) + .arg("--manifest-path") + .arg("src/main.rs") + .run(); + + assert!(p.root().join(lockfile_path).is_file()); + + p.cargo("run") + .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("-Zunstable-options") + .arg("-Zscript") + .arg("--lockfile-path") + .arg(invalid_lockfile) + .arg("--manifest-path") + .arg("src/main.rs") + .with_status(101) + .with_stderr_data(str![[r#" +[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead +[WARNING] `package.edition` is unspecified, defaulting to `2024` +[ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock +... +"#]]) + .run(); +} + #[cargo_test] fn cli_ignored_when_config_set() { let lockfile_path = "mylockfile/Cargo.lock"; From 807e8bf0895b451565f2f4475950c4da3dec18c8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:53:39 -0600 Subject: [PATCH 07/11] test(lockfile): Port CLI tests to config --- tests/testsuite/lockfile_path.rs | 154 ++++++++++++++++--------------- 1 file changed, 81 insertions(+), 73 deletions(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index d4ca85112e3..93a3a8c6ff7 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -51,11 +51,10 @@ fn config_basic_lockfile_read() { let lockfile_path = "mylockfile/Cargo.lock"; let p = make_project().file(lockfile_path, VALID_LOCKFILE).build(); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .run(); assert!(!p.root().join("Cargo.lock").exists()); @@ -69,11 +68,10 @@ fn config_basic_lockfile_override() { .file("Cargo.lock", "This is an invalid lock file!") .build(); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .run(); assert!(p.root().join(lockfile_path).is_file()); @@ -94,11 +92,10 @@ fn config_symlink_in_path() { fs::create_dir(p.root().join("dst")).unwrap(); assert!(p.root().join(src).is_dir()); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path.as_str()) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .run(); assert!(p.root().join(lockfile_path).is_file()); @@ -122,11 +119,10 @@ fn config_symlink_lockfile() { assert!(p.root().join(src).is_file()); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .run(); assert!(!p.root().join("Cargo.lock").exists()); @@ -145,14 +141,12 @@ fn config_broken_symlink() { let p = make_project().symlink_dir(invalid_dst, src).build(); assert!(!p.root().join(src).is_dir()); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .with_status(101) .with_stderr_data(str![[r#" -[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead [ERROR] failed to create directory `[ROOT]/foo/somedir/link` ... @@ -176,14 +170,12 @@ fn config_loop_symlink() { .build(); assert!(!p.root().join(src).is_dir()); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .with_status(101) .with_stderr_data(str![[r#" -[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead [ERROR] failed to create directory `[ROOT]/foo/somedir/link` ... @@ -202,11 +194,10 @@ fn config_add_lockfile_override() { let p = make_project() .file("Cargo.lock", "This is an invalid lock file!") .build(); - p.cargo("add") + p.cargo("add -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .arg("--path") .arg("../bar") .run(); @@ -220,11 +211,10 @@ fn config_clean_lockfile_override() { let p = make_project() .file("Cargo.lock", "This is an invalid lock file!") .build(); - p.cargo("clean") + p.cargo("clean -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .arg("--package") .arg("test_foo") .run(); @@ -238,17 +228,28 @@ fn config_fix_lockfile_override() { let p = make_project() .file("Cargo.lock", "This is an invalid lock file!") .build(); - p.cargo("fix") + p.cargo("fix -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .arg("--package") .arg("test_foo") .arg("--allow-no-vcs") + .with_status(101) + .with_stderr_data(str![[r#" +[ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock + +Caused by: + TOML parse error at line 1, column 6 + | + 1 | This is an invalid lock file! + | ^ + key with no value, expected `=` + +"#]]) .run(); - assert!(p.root().join(lockfile_path).is_file()); + assert!(!p.root().join(lockfile_path).is_file()); } #[cargo_test] @@ -257,11 +258,10 @@ fn config_publish_lockfile_read() { let p = make_project().file(lockfile_path, VALID_LOCKFILE).build(); let registry = RegistryBuilder::new().http_api().http_index().build(); - p.cargo("publish") + p.cargo("publish -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .replace_crates_io(registry.index_url()) .run(); @@ -299,11 +299,10 @@ fn config_remove_lockfile_override() { .file("src/main.rs", "fn main() {}") .file("Cargo.lock", "This is an invalid lock file!") .build(); - p.cargo("remove") + p.cargo("remove -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .arg("test_bar") .run(); @@ -336,11 +335,10 @@ bar = "0.1.0" .build(); Package::new("bar", "0.1.0").publish(); - p.cargo("generate-lockfile") + p.cargo("generate-lockfile -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .run(); assert!(!p.root().join("Cargo.lock").exists()); @@ -349,11 +347,10 @@ bar = "0.1.0" let lockfile_original = fs::read_to_string(p.root().join(lockfile_path)).unwrap(); Package::new("bar", "0.1.1").publish(); - p.cargo("package") + p.cargo("package -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .run(); assert!( @@ -401,7 +398,9 @@ dependencies = [ ) .publish(); - cargo_process("install foo --locked") + let p = project().at("install").build(); + + p.cargo("install foo --locked") .with_stderr_data(str![[r#" ... [..]not rust[..] @@ -429,12 +428,25 @@ dependencies = [ "#, ) .build(); - cargo_process("install foo -Zunstable-options --lockfile-path foo/Cargo.lock") + p.cargo("install foo -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) + .arg("--config") + .arg("resolver.lockfile-path='../foo/Cargo.lock'") + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[INSTALLING] foo v0.1.0 +[LOCKING] 1 package to latest compatible version +[COMPILING] bar v0.1.1 +... +[ERROR] could not compile `bar` (lib) due to 1 previous error +[ERROR] failed to compile `foo v0.1.0`, intermediate artifacts can be found at `[..]`. +To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path. + +"#]]) + .with_status(101) .run(); assert!(paths::root().join("foo/Cargo.lock").is_file()); - assert_has_installed_exe(paths::cargo_home(), "foo"); } #[cargo_test] @@ -450,14 +462,12 @@ fn config_install_lock_file_path_must_present() { ) .publish(); - cargo_process("install foo -Zunstable-options --lockfile-path lockfile_dir/Cargo.lock") + let p = project().at("install").build(); + + p.cargo("install foo -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .with_stderr_data(str![[r#" -... -[ERROR] no Cargo.lock file found in the requested path [ROOT]/lockfile_dir/Cargo.lock -... -"#]]) - .with_status(101) + .arg("--config") + .arg("resolver.lockfile-path='../lockfile_dir/Cargo.lock'") .run(); } @@ -470,29 +480,27 @@ fn config_run_embed() { .file("Cargo.lock", "This is an invalid lock file!") .build(); - p.cargo("run") + p.cargo("run -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) - .arg("-Zunstable-options") .arg("-Zscript") - .arg("--lockfile-path") - .arg(lockfile_path) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{lockfile_path}'")) .arg("--manifest-path") .arg("src/main.rs") .run(); assert!(p.root().join(lockfile_path).is_file()); - p.cargo("run") + p.cargo("run -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("-Zunstable-options") .arg("-Zscript") - .arg("--lockfile-path") - .arg(invalid_lockfile) + .arg("--config") + .arg(&format!("resolver.lockfile-path='{invalid_lockfile}'")) .arg("--manifest-path") .arg("src/main.rs") .with_status(101) .with_stderr_data(str![[r#" -[WARNING] the `--lockfile-path` flag is deprecated and will be removed in a future release, use `resolver.lockfile-path` config instead [WARNING] `package.edition` is unspecified, defaulting to `2024` [ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock ... From c943d1f1262455efafe49ab3657e1b22b14cf7f1 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:55:12 -0600 Subject: [PATCH 08/11] refactor(fix): Remove unused variable --- src/bin/cargo/commands/fix.rs | 1 - src/cargo/ops/fix/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index d9893a27da4..538e88af36a 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -102,7 +102,6 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { allow_staged: allow_dirty || args.flag("allow-staged"), allow_no_vcs: args.flag("allow-no-vcs"), broken_code: args.flag("broken-code"), - requested_lockfile_path: lockfile_path, }; if let Some(fe) = &gctx.cli_unstable().fix_edition { diff --git a/src/cargo/ops/fix/mod.rs b/src/cargo/ops/fix/mod.rs index dfde71d3095..6bd0199a494 100644 --- a/src/cargo/ops/fix/mod.rs +++ b/src/cargo/ops/fix/mod.rs @@ -100,7 +100,6 @@ pub struct FixOptions { pub allow_no_vcs: bool, pub allow_staged: bool, pub broken_code: bool, - pub requested_lockfile_path: Option, } /// The behavior of `--edition` migration. From 04a8f688438c00bb3b96435e54a98eba9c0f682c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 9 Feb 2026 16:57:33 -0600 Subject: [PATCH 09/11] fix(fix): Respect resolver.lockfile-path But didn't bother with conflict errors with `--lockfile-path`. If it is missing, oh well, it will go away soon. --- src/bin/cargo/commands/fix.rs | 4 +++- tests/testsuite/lockfile_path.rs | 14 +------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 538e88af36a..eb2dda73974 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -77,7 +77,9 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { let mut ws = Workspace::new(&root_manifest, gctx)?; ws.set_resolve_honors_rust_version(args.honor_rust_version()); let lockfile_path = args.lockfile_path(gctx)?; - ws.set_requested_lockfile_path(lockfile_path.clone()); + if ws.requested_lockfile_path().is_none() { + ws.set_requested_lockfile_path(lockfile_path.clone()); + } let mut opts = args.compile_options(gctx, intent, Some(&ws), ProfileChecking::LegacyTestOnly)?; diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index 93a3a8c6ff7..b5c0736d774 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -235,21 +235,9 @@ fn config_fix_lockfile_override() { .arg("--package") .arg("test_foo") .arg("--allow-no-vcs") - .with_status(101) - .with_stderr_data(str![[r#" -[ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock - -Caused by: - TOML parse error at line 1, column 6 - | - 1 | This is an invalid lock file! - | ^ - key with no value, expected `=` - -"#]]) .run(); - assert!(!p.root().join(lockfile_path).is_file()); + assert!(p.root().join(lockfile_path).is_file()); } #[cargo_test] From 5511201690b91acaae57a218afea1efada29e633 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 10 Feb 2026 08:44:56 -0600 Subject: [PATCH 10/11] test(lockfile): Explicit --locked for config --- tests/testsuite/lockfile_path.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index b5c0736d774..b698e779e85 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -416,20 +416,14 @@ dependencies = [ "#, ) .build(); - p.cargo("install foo -Zlockfile-path") + p.cargo("install foo --locked -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("--config") .arg("resolver.lockfile-path='../foo/Cargo.lock'") .with_stderr_data(str![[r#" -[UPDATING] `dummy-registry` index -[INSTALLING] foo v0.1.0 -[LOCKING] 1 package to latest compatible version -[COMPILING] bar v0.1.1 ... -[ERROR] could not compile `bar` (lib) due to 1 previous error -[ERROR] failed to compile `foo v0.1.0`, intermediate artifacts can be found at `[..]`. -To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path. - +[..]not rust[..] +... "#]]) .with_status(101) .run(); @@ -452,7 +446,7 @@ fn config_install_lock_file_path_must_present() { let p = project().at("install").build(); - p.cargo("install foo -Zlockfile-path") + p.cargo("install foo --locked -Zlockfile-path") .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("--config") .arg("resolver.lockfile-path='../lockfile_dir/Cargo.lock'") From 387d0b7f2ae193d8ec19ee82fe015befd497a065 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 10 Feb 2026 08:46:40 -0600 Subject: [PATCH 11/11] fix(instal): Respect resolver.lockfile-path --- src/cargo/ops/cargo_install.rs | 4 +++- tests/testsuite/lockfile_path.rs | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 0d18ba4670e..811f926e8c8 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -879,7 +879,9 @@ fn make_ws_rustc_target<'gctx>( }; ws.set_resolve_feature_unification(FeatureUnification::Selected); ws.set_ignore_lock(gctx.lock_update_allowed()); - ws.set_requested_lockfile_path(lockfile_path.map(|p| p.to_path_buf())); + if ws.requested_lockfile_path().is_none() { + ws.set_requested_lockfile_path(lockfile_path.map(|p| p.to_path_buf())); + } // if --lockfile-path is set, imply --locked if ws.requested_lockfile_path().is_some() { ws.set_ignore_lock(false); diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index b698e779e85..c399e7b7e3f 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -420,15 +420,10 @@ dependencies = [ .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("--config") .arg("resolver.lockfile-path='../foo/Cargo.lock'") - .with_stderr_data(str![[r#" -... -[..]not rust[..] -... -"#]]) - .with_status(101) .run(); assert!(paths::root().join("foo/Cargo.lock").is_file()); + assert_has_installed_exe(paths::cargo_home(), "foo"); } #[cargo_test] @@ -450,6 +445,12 @@ fn config_install_lock_file_path_must_present() { .masquerade_as_nightly_cargo(&["lockfile-path"]) .arg("--config") .arg("resolver.lockfile-path='../lockfile_dir/Cargo.lock'") + .with_stderr_data(str![[r#" +... +[ERROR] no Cargo.lock file found in the requested path [ROOT]/install/../lockfile_dir/Cargo.lock +... +"#]]) + .with_status(101) .run(); }