summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/lockfile_compat.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /src/tools/cargo/tests/testsuite/lockfile_compat.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/lockfile_compat.rs')
-rw-r--r--src/tools/cargo/tests/testsuite/lockfile_compat.rs78
1 files changed, 78 insertions, 0 deletions
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);
+}