Add test case for issue #1111, by adding another route by which a test file's config can be located

This commit is contained in:
Stuart Dootson 2016-08-08 23:13:45 +02:00
parent 69f647b9f1
commit cb0b7108ca
4 changed files with 11 additions and 1 deletions

1
tests/config/issue-1111.toml Executable file
View File

@ -0,0 +1 @@
reorder_imports = true

View File

@ -0,0 +1 @@
use bar;

View File

@ -205,7 +205,11 @@ fn print_mismatches(result: HashMap<String, Vec<Mismatch>>) {
fn read_config(filename: &str) -> Config {
let sig_comments = read_significant_comments(&filename);
let mut config = get_config(sig_comments.get("config").map(|x| &(*x)[..]));
let mut config = if !sig_comments.is_empty() {
get_config(sig_comments.get("config").map(|x| &(*x)[..]))
} else {
get_config(Path::new(filename).with_extension("toml").file_name().and_then(std::ffi::OsStr::to_str))
};
for (key, val) in &sig_comments {
if key != "target" && key != "config" {
@ -253,6 +257,9 @@ fn get_config(config_file: Option<&str>) -> Config {
Some(file_name) => {
let mut full_path = "tests/config/".to_owned();
full_path.push_str(&file_name);
if !Path::new(&full_path).exists() {
return Default::default();
};
full_path
}
};

View File

@ -0,0 +1 @@
use bar;