From c7c28d9de78b5aaccb96c85df7bd559db66c9637 Mon Sep 17 00:00:00 2001 From: Heng-Yi Wu <2316687+henry40408@users.noreply.github.com> Date: Tue, 18 Jun 2024 06:14:46 +0800 Subject: [PATCH] test: migrate testsuite precise_pre_release to snapbox --- tests/testsuite/precise_pre_release.rs | 37 +++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/testsuite/precise_pre_release.rs b/tests/testsuite/precise_pre_release.rs index c3030fe39347..822e537b360c 100644 --- a/tests/testsuite/precise_pre_release.rs +++ b/tests/testsuite/precise_pre_release.rs @@ -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() { @@ -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() } @@ -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\"")); @@ -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();