From cb0b7108ca32caacb4c7d7c8beff24966d2485e1 Mon Sep 17 00:00:00 2001 From: Stuart Dootson Date: Mon, 8 Aug 2016 23:13:45 +0200 Subject: [PATCH] Add test case for issue #1111, by adding another route by which a test file's config can be located --- tests/config/issue-1111.toml | 1 + tests/source/issue-1111.rs | 1 + tests/system.rs | 9 ++++++++- tests/target/issue-1111.rs | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100755 tests/config/issue-1111.toml create mode 100644 tests/source/issue-1111.rs create mode 100644 tests/target/issue-1111.rs diff --git a/tests/config/issue-1111.toml b/tests/config/issue-1111.toml new file mode 100755 index 000000000000..44148a2d3c3e --- /dev/null +++ b/tests/config/issue-1111.toml @@ -0,0 +1 @@ +reorder_imports = true diff --git a/tests/source/issue-1111.rs b/tests/source/issue-1111.rs new file mode 100644 index 000000000000..2e1a89ad78eb --- /dev/null +++ b/tests/source/issue-1111.rs @@ -0,0 +1 @@ +use bar; diff --git a/tests/system.rs b/tests/system.rs index 08ec576f2218..0e24505260e2 100644 --- a/tests/system.rs +++ b/tests/system.rs @@ -205,7 +205,11 @@ fn print_mismatches(result: HashMap>) { 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 } }; diff --git a/tests/target/issue-1111.rs b/tests/target/issue-1111.rs new file mode 100644 index 000000000000..2e1a89ad78eb --- /dev/null +++ b/tests/target/issue-1111.rs @@ -0,0 +1 @@ +use bar;