@@ -1,24 +1,26 @@
1−#![cfg(test)]
1+fn main() {}
22
3−extern crate compiletest_rs as compiletest;
3+#[cfg(test)]
4+mod tests {
5+ extern crate compiletest_rs as compiletest;
6+ use std::path::PathBuf;
47
5−use std::path::PathBuf;
8+ fn run_mode(mode: &'static str) {
9+ let mut config = self::compiletest::Config::default();
610
7−fn run_mode(mode: &'static str) {
8− let mut config = compiletest::Config::default();
11+ config.mode = mode.parse().expect("Invalid mode");
12+ config.src_base = PathBuf::from(format!("{}", mode));
913
10− config.mode = mode.parse().expect("Invalid mode");
11− config.src_base = PathBuf::from(format!("{}", mode));
14+ // Populate config.target_rustcflags with dependencies on the path.
15+ config.link_deps();
16+ // If your tests import the parent crate, this helps with E0464
17+ config.clean_rmeta();
1218
13− // Populate config.target_rustcflags with dependencies on the path.
14− config.link_deps();
15− // If your tests import the parent crate, this helps with E0464
16− config.clean_rmeta();
19+ compiletest::run_tests(&config);
20+ }
1721
18− compiletest::run_tests(&config);
19−}
20−
21−#[test]
22−fn compile_test() {
23− run_mode("compile-fail");
22+ #[test]
23+ fn compile_test() {
24+ run_mode("compile-fail");
25+ }
2426}