From 4ac0d35ebb8aeae27c8861850b59a747ac44f194 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sun, 12 May 2019 23:03:48 +0200 Subject: [PATCH] Only run test on nightly --- src/test/mod.rs | 27 ++++++++++++++----- .../normalize_multiline_doc_attribute.rs | 2 ++ .../normalize_multiline_doc_attribute.rs | 2 ++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/test/mod.rs b/src/test/mod.rs index 23f6a69b8d18..20c4bce5d816 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -259,9 +259,9 @@ fn assert_output(source: &Path, expected_filename: &Path) { #[test] fn idempotence_tests() { run_test_with(&TestSetting::default(), || { - match option_env!("CFG_RELEASE_CHANNEL") { - None | Some("nightly") => {} - _ => return, // these tests require nightly + // these tests require nightly + if !is_nightly() { + return; } // Get all files in the tests/target directory. let files = get_test_files(Path::new("tests/target"), true); @@ -277,9 +277,9 @@ fn idempotence_tests() { // no warnings are emitted. #[test] fn self_tests() { - match option_env!("CFG_RELEASE_CHANNEL") { - None | Some("nightly") => {} - _ => return, // Issue-3443: these tests require nightly + // Issue-3443: these tests require nightly + if !is_nightly() { + return; } let mut files = get_test_files(Path::new("tests"), false); let bin_directories = vec!["cargo-fmt", "git-rustfmt", "bin", "format-diff"]; @@ -313,6 +313,11 @@ 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()); @@ -426,6 +431,16 @@ fn check_files(files: Vec, opt_config: &Option) -> (Vec