mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
feat(test-support): Expose masquerade_as_nightly_cargo
to snapbox users
This commit is contained in:
parent
0d135a0b43
commit
79ef00c60b
@ -59,6 +59,10 @@ pub mod publish;
|
|||||||
pub mod registry;
|
pub mod registry;
|
||||||
pub mod tools;
|
pub mod tools;
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
pub use crate::ChannelChanger;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* ===== Builders =====
|
* ===== Builders =====
|
||||||
@ -1169,12 +1173,19 @@ fn _process(t: &OsStr) -> ProcessBuilder {
|
|||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ChannelChanger: Sized {
|
/// Enable nightly features for testing
|
||||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self;
|
pub trait ChannelChanger {
|
||||||
|
fn masquerade_as_nightly_cargo(self) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelChanger for ProcessBuilder {
|
impl ChannelChanger for &mut ProcessBuilder {
|
||||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self {
|
fn masquerade_as_nightly_cargo(self) -> Self {
|
||||||
|
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChannelChanger for snapbox::cmd::Command {
|
||||||
|
fn masquerade_as_nightly_cargo(self) -> Self {
|
||||||
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
|
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use cargo_test_support::cargo_exe;
|
use cargo_test_support::cargo_exe;
|
||||||
use cargo_test_support::compare::assert;
|
use cargo_test_support::compare::assert;
|
||||||
|
use cargo_test_support::prelude::*;
|
||||||
use cargo_test_support::Project;
|
use cargo_test_support::Project;
|
||||||
|
|
||||||
pub fn cargo_command() -> snapbox::cmd::Command {
|
pub fn cargo_command() -> snapbox::cmd::Command {
|
||||||
@ -50,16 +51,6 @@ pub fn cargo_command() -> snapbox::cmd::Command {
|
|||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait CommandExt {
|
|
||||||
fn masquerade_as_nightly_cargo(self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CommandExt for snapbox::cmd::Command {
|
|
||||||
fn masquerade_as_nightly_cargo(self) -> Self {
|
|
||||||
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_registry() {
|
fn init_registry() {
|
||||||
cargo_test_support::registry::init();
|
cargo_test_support::registry::init();
|
||||||
add_registry_packages(false);
|
add_registry_packages(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user