mirror of https://github.com/rust-lang/cargo
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 tools;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::ChannelChanger;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* ===== Builders =====
|
||||
|
@ -1169,12 +1173,19 @@ fn _process(t: &OsStr) -> ProcessBuilder {
|
|||
p
|
||||
}
|
||||
|
||||
pub trait ChannelChanger: Sized {
|
||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self;
|
||||
/// Enable nightly features for testing
|
||||
pub trait ChannelChanger {
|
||||
fn masquerade_as_nightly_cargo(self) -> Self;
|
||||
}
|
||||
|
||||
impl ChannelChanger for ProcessBuilder {
|
||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self {
|
||||
impl ChannelChanger for &mut ProcessBuilder {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use cargo_test_support::cargo_exe;
|
||||
use cargo_test_support::compare::assert;
|
||||
use cargo_test_support::prelude::*;
|
||||
use cargo_test_support::Project;
|
||||
|
||||
pub fn cargo_command() -> snapbox::cmd::Command {
|
||||
|
@ -50,16 +51,6 @@ pub fn cargo_command() -> snapbox::cmd::Command {
|
|||
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() {
|
||||
cargo_test_support::registry::init();
|
||||
add_registry_packages(false);
|
||||
|
|
Loading…
Reference in New Issue