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