Re-use nightly channel macro

This commit is contained in:
Ruben Schmidmeister 2019-05-17 16:07:49 +02:00
parent fd22c27c47
commit 4745cec7f3
No known key found for this signature in database
GPG Key ID: 29387B5A7AAF863F
2 changed files with 5 additions and 8 deletions

View File

@ -60,6 +60,7 @@ fn doc_hint() -> String {
/// 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")

View File

@ -14,6 +14,7 @@
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...",