diff options
| -rw-r--r-- | src/config/config_type.rs | 1 | ||||
| -rw-r--r-- | src/test/mod.rs | 12 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/config/config_type.rs b/src/config/config_type.rs index d14969418ad..26cd672f83a 100644 --- a/src/config/config_type.rs +++ b/src/config/config_type.rs @@ -60,6 +60,7 @@ impl ConfigType for IgnoreList { /// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`), /// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the /// nightly compiler when installed from crates.io, default to nightly mode. +#[macro_export] macro_rules! is_nightly_channel { () => { option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev") diff --git a/src/test/mod.rs b/src/test/mod.rs index 101a8c07fd9..d3e18130977 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -14,6 +14,7 @@ use crate::formatting::{ReportedErrors, SourceFile}; use crate::rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, ModifiedChunk, OutputWriter}; use crate::source_file; use crate::{FormatReport, FormatReportFormatterBuilder, Input, Session}; +use crate::is_nightly_channel; const DIFF_CONTEXT_SIZE: usize = 3; const CONFIGURATIONS_FILE_NAME: &str = "Configurations.md"; @@ -260,7 +261,7 @@ fn assert_output(source: &Path, expected_filename: &Path) { fn idempotence_tests() { run_test_with(&TestSetting::default(), || { // these tests require nightly - if !is_nightly() { + if !is_nightly_channel!() { return; } // Get all files in the tests/target directory. @@ -278,7 +279,7 @@ fn idempotence_tests() { #[test] fn self_tests() { // Issue-3443: these tests require nightly - if !is_nightly() { + if !is_nightly_channel!() { return; } let mut files = get_test_files(Path::new("tests"), false); @@ -313,11 +314,6 @@ fn self_tests() { ); } -fn is_nightly() -> bool { - let release_channel = option_env!("CFG_RELEASE_CHANNEL"); - release_channel.is_none() || release_channel == Some("nightly") -} - #[test] fn stdin_formatting_smoke_test() { let input = Input::Text("fn main () {}".to_owned()); @@ -432,7 +428,7 @@ fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<Format for file_name in files { let sig_comments = read_significant_comments(&file_name); - if sig_comments.contains_key("unstable") && !is_nightly() { + if sig_comments.contains_key("unstable") && !is_nightly_channel!() { debug!( "Skipping '{}' because it requires unstable \ features which are only available on nightly...", |
