From 7fc4e418bfcc77b2ff6fc63cd542442d203b5eab Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sun, 17 Mar 2019 12:27:24 +0900 Subject: [PATCH] Tweak test settings --- src/test/mod.rs | 15 ++++++++++++++- tests/source/configs/skip_children/foo/mod.rs | 3 +++ tests/target/configs/skip_children/foo/mod.rs | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/source/configs/skip_children/foo/mod.rs create mode 100644 tests/target/configs/skip_children/foo/mod.rs diff --git a/src/test/mod.rs b/src/test/mod.rs index 20845b08f83..98f81cbe245 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -17,6 +17,19 @@ use crate::{FormatReport, Input, Session}; const DIFF_CONTEXT_SIZE: usize = 3; const CONFIGURATIONS_FILE_NAME: &str = "Configurations.md"; +// A list of files on which we want to skip testing. +const SKIP_FILE_WHITE_LIST: &[&str] = &[ + // We want to make sure that the `skip_children` is correctly working, + // so we do not want to test this file directly. + "configs/skip_children/foo/mod.rs", +]; + +fn is_file_skip(path: &Path) -> bool { + SKIP_FILE_WHITE_LIST + .iter() + .any(|file_path| path.ends_with(file_path)) +} + // Returns a `Vec` containing `PathBuf`s of files with an `rs` extension in the // given path. The `recursive` argument controls if files from subdirectories // are also returned. @@ -31,7 +44,7 @@ fn get_test_files(path: &Path, recursive: bool) -> Vec { let path = entry.path(); if path.is_dir() && recursive { files.append(&mut get_test_files(&path, recursive)); - } else if path.extension().map_or(false, |f| f == "rs") { + } else if path.extension().map_or(false, |f| f == "rs") && !is_file_skip(&path) { files.push(path); } } diff --git a/tests/source/configs/skip_children/foo/mod.rs b/tests/source/configs/skip_children/foo/mod.rs new file mode 100644 index 00000000000..d7ff6cdb829 --- /dev/null +++ b/tests/source/configs/skip_children/foo/mod.rs @@ -0,0 +1,3 @@ +fn skip_formatting_this() { + println ! ( "Skip this" ) ; +} diff --git a/tests/target/configs/skip_children/foo/mod.rs b/tests/target/configs/skip_children/foo/mod.rs new file mode 100644 index 00000000000..d7ff6cdb829 --- /dev/null +++ b/tests/target/configs/skip_children/foo/mod.rs @@ -0,0 +1,3 @@ +fn skip_formatting_this() { + println ! ( "Skip this" ) ; +}