blob: 8593c01f744ac4afe66d23020849d2a8ae7fe7ab [file] [log] [blame]
David Tolnayc7a5d3d2017-06-04 12:11:05 -07001#![allow(dead_code)]
2
Nika Layzella2a1a4a2017-11-19 11:33:17 -05003extern crate syntax;
David Tolnay51382052017-12-27 13:46:21 -05004extern crate walkdir;
Michael Layzell53fc31a2017-06-07 09:21:53 -04005
David Tolnayee97dbf2017-11-19 14:24:38 -08006use std;
Michael Layzell53fc31a2017-06-07 09:21:53 -04007use std::env;
Alex Crichton86374772017-07-07 20:39:28 -07008use std::process::Command;
Michael Layzell53fc31a2017-06-07 09:21:53 -04009
David Tolnayc7a5d3d2017-06-04 12:11:05 -070010use self::walkdir::DirEntry;
11
David Tolnayecd024d2018-07-21 09:07:56 -070012pub mod eq;
Michael Layzell53fc31a2017-06-07 09:21:53 -040013pub mod parse;
Michael Layzell53fc31a2017-06-07 09:21:53 -040014
Michael Layzell53fc31a2017-06-07 09:21:53 -040015/// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it.
David Tolnayee97dbf2017-11-19 14:24:38 -080016pub fn abort_after() -> usize {
17 match env::var("ABORT_AFTER_FAILURE") {
18 Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"),
19 Err(_) => std::usize::MAX,
Michael Layzell53fc31a2017-06-07 09:21:53 -040020 }
Michael Layzell53fc31a2017-06-07 09:21:53 -040021}
22
23pub fn base_dir_filter(entry: &DirEntry) -> bool {
24 let path = entry.path();
25 if path.is_dir() {
26 return true; // otherwise walkdir does not visit the files
27 }
28 if path.extension().map(|e| e != "rs").unwrap_or(true) {
29 return false;
30 }
31 let path_string = path.to_string_lossy();
32 let path_string = if cfg!(windows) {
33 path_string.replace('\\', "/").into()
34 } else {
35 path_string
36 };
37 // TODO assert that parsing fails on the parse-fail cases
David Tolnay51382052017-12-27 13:46:21 -050038 if path_string.starts_with("tests/rust/src/test/parse-fail")
39 || path_string.starts_with("tests/rust/src/test/compile-fail")
David Tolnayd7c5d022018-07-21 14:32:55 -070040 || path_string.starts_with("tests/rust/src/test/rustfix")
David Tolnay51382052017-12-27 13:46:21 -050041 {
Michael Layzell53fc31a2017-06-07 09:21:53 -040042 return false;
43 }
44
45 if path_string.starts_with("tests/rust/src/test/ui") {
46 let stderr_path = path.with_extension("stderr");
47 if stderr_path.exists() {
48 // Expected to fail in some way
49 return false;
50 }
51 }
52
53 match path_string.as_ref() {
David Tolnayd7c5d022018-07-21 14:32:55 -070054 // Deprecated placement syntax
55 "tests/rust/src/test/run-pass/new-box-syntax.rs" |
56 "tests/rust/src/test/ui/obsolete-in-place/bad.rs" |
David Tolnay13b6a132018-03-31 20:38:58 +020057 // not actually test cases
David Tolnay54a8fee2018-10-27 22:48:31 -070058 "tests/rust/src/test/run-pass/macros/auxiliary/macro-comma-support.rs" |
59 "tests/rust/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs" |
David Tolnaye9ceb542018-08-21 21:04:33 -040060 "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false,
Michael Layzell53fc31a2017-06-07 09:21:53 -040061 _ => true,
62 }
63}
64
Alex Crichton86374772017-07-07 20:39:28 -070065pub fn clone_rust() {
David Tolnayed8716e2017-12-25 21:49:39 -050066 let result = Command::new("tests/clone.sh").status().unwrap();
Alex Crichton86374772017-07-07 20:39:28 -070067 println!("result: {}", result);
68 assert!(result.success());
69}