compiletest.rs 649 B

12345678910111213141516171819202122232425
  1. extern crate compiletest_rs as compiletest;
  2. use std::path::PathBuf;
  3. use std::env::var;
  4. fn run_mode(mode: &'static str) {
  5. let mut config = compiletest::default_config();
  6. let cfg_mode = mode.parse().ok().expect("Invalid mode");
  7. config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned());
  8. if let Ok(name) = var::<&str>("TESTNAME") {
  9. let s : String = name.to_owned();
  10. config.filter = Some(s)
  11. }
  12. config.mode = cfg_mode;
  13. config.src_base = PathBuf::from(format!("tests/{}", mode));
  14. compiletest::run_tests(&config);
  15. }
  16. #[test]
  17. fn compile_test() {
  18. run_mode("compile-fail");
  19. }