From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/cargo/tests/testsuite/lockfile_compat.rs | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'src/tools/cargo/tests/testsuite/lockfile_compat.rs') diff --git a/src/tools/cargo/tests/testsuite/lockfile_compat.rs b/src/tools/cargo/tests/testsuite/lockfile_compat.rs index aad8723c3..63148cc07 100644 --- a/src/tools/cargo/tests/testsuite/lockfile_compat.rs +++ b/src/tools/cargo/tests/testsuite/lockfile_compat.rs @@ -888,3 +888,81 @@ perhaps a crate was updated and forgotten to be re-vendored? ) .run(); } + +#[cargo_test] +fn v4_is_unstable() { + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.0.1" + "#, + ), + ) + .file("src/lib.rs", "") + .file("Cargo.lock", "version = 4") + .build(); + + p.cargo("fetch") + .with_status(101) + .with_stderr( + "\ +error: failed to parse lock file at: [CWD]/Cargo.lock + +Caused by: + lock file version `4` was found, but this version of Cargo does not \ + understand this lock file, perhaps Cargo needs to be updated? +", + ) + .run(); + + // On nightly, let the user know about the `-Z` flag. + p.cargo("fetch") + .masquerade_as_nightly_cargo(&["-Znext-lockfile-bump"]) + .with_status(101) + .with_stderr( + "\ +error: failed to parse lock file at: [CWD]/Cargo.lock + +Caused by: + lock file version 4 requires `-Znext-lockfile-bump` +", + ) + .run(); +} + +#[cargo_test] +fn v4_cannot_be_created_from_scratch() { + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.0.1" + "#, + ), + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("fetch -Znext-lockfile-bump") + .masquerade_as_nightly_cargo(&["-Znext-lockfile-bump"]) + .run(); + + let lockfile = r#"# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "foo" +version = "0.0.1" +"#; + + let lock = p.read_lockfile(); + assert_match_exact(lockfile, &lock); +} -- cgit v1.2.3