Skip to content

Commit

Permalink
test: migrate testsuite precise_pre_release to snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
henry40408 committed Jun 18, 2024
1 parent fe4e792 commit 190edb8
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions tests/testsuite/precise_pre_release.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Tests for selecting pre-release versions with `update --precise`.

#![allow(deprecated)]

use cargo_test_support::project;
use cargo_test_support::{project, str};

#[cargo_test]
fn requires_nightly_cargo() {
Expand All @@ -29,16 +27,17 @@ fn requires_nightly_cargo() {
.with_status(101)
// This error is suffering from #12579 but still demonstrates that updating to
// a pre-release does not work on stable
.with_stderr(
r#"[UPDATING] `dummy-registry` index
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] failed to select a version for the requirement `my-dependency = "^0.1.1"`
candidate versions found which didn't match: 0.1.2-pre.0
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `package v0.0.0 ([ROOT]/foo)`
if you are looking for the prerelease package it needs to be specified explicitly
my-dependency = { version = "0.1.2-pre.0" }
perhaps a crate was updated and forgotten to be re-vendored?"#,
)
perhaps a crate was updated and forgotten to be re-vendored?
"#]])
.run()
}

Expand All @@ -65,11 +64,11 @@ fn update_pre_release() {

p.cargo("update my-dependency --precise 0.1.2-pre.0 -Zunstable-options")
.masquerade_as_nightly_cargo(&["precise-pre-release"])
.with_stderr(
r#"[UPDATING] `dummy-registry` index
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[UPDATING] my-dependency v0.1.1 -> v0.1.2-pre.0
"#,
)
"#]])
.run();
let lockfile = p.read_lockfile();
assert!(lockfile.contains("\nname = \"my-dependency\"\nversion = \"0.1.2-pre.0\""));
Expand Down Expand Up @@ -98,20 +97,20 @@ fn update_pre_release_differ() {

p.cargo("update -p my-dependency --precise 0.1.2-pre.0 -Zunstable-options")
.masquerade_as_nightly_cargo(&["precise-pre-release"])
.with_stderr(
r#"[UPDATING] `dummy-registry` index
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[DOWNGRADING] my-dependency v0.1.2 -> v0.1.2-pre.0
"#,
)
"#]])
.run();

p.cargo("update -p my-dependency --precise 0.1.2-pre.1 -Zunstable-options")
.masquerade_as_nightly_cargo(&["precise-pre-release"])
.with_stderr(
r#"[UPDATING] `dummy-registry` index
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[UPDATING] my-dependency v0.1.2-pre.0 -> v0.1.2-pre.1
"#,
)
"#]])
.run();

let lockfile = p.read_lockfile();
Expand Down

0 comments on commit 190edb8

Please sign in to comment.