diff options
| author | Ruben Schmidmeister <ruben.schmidmeister@icloud.com> | 2019-05-17 15:58:01 +0200 |
|---|---|---|
| committer | Ruben Schmidmeister <ruben.schmidmeister@icloud.com> | 2019-05-17 15:58:01 +0200 |
| commit | fd22c27c47a71cff2f92e61b11b3344ed9e50d25 (patch) | |
| tree | 8813874eab712913e270b645dffbc30fdbca5059 /src/test | |
| parent | c97aa152dac4b27e7cba692abed0fea2fcce2bd4 (diff) | |
Allow tests to be run on nightly only
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/mod.rs | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/test/mod.rs b/src/test/mod.rs index 23f6a69b8d1..101a8c07fd9 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<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<Format let mut reports = vec![]; for file_name in files { + let sig_comments = read_significant_comments(&file_name); + if sig_comments.contains_key("unstable") && !is_nightly() { + debug!( + "Skipping '{}' because it requires unstable \ + features which are only available on nightly...", + file_name.display() + ); + continue; + } + debug!("Testing '{}'...", file_name.display()); match idempotent_check(&file_name, &opt_config) { @@ -485,7 +500,7 @@ fn read_config(filename: &Path) -> Config { }; for (key, val) in &sig_comments { - if key != "target" && key != "config" { + if key != "target" && key != "config" && key != "unstable" { config.override_value(key, val); if config.is_default(key) { warn!("Default value {} used explicitly for {}", val, key); |
