David Tolnay | c7a5d3d | 2017-06-04 12:11:05 -0700 | [diff] [blame] | 1 | #![allow(dead_code)] |
| 2 | |
Nika Layzell | a2a1a4a | 2017-11-19 11:33:17 -0500 | [diff] [blame] | 3 | extern crate syntax; |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 4 | extern crate walkdir; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 5 | |
David Tolnay | ee97dbf | 2017-11-19 14:24:38 -0800 | [diff] [blame] | 6 | use std; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 7 | use std::env; |
Alex Crichton | 8637477 | 2017-07-07 20:39:28 -0700 | [diff] [blame] | 8 | use std::process::Command; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 9 | |
David Tolnay | c7a5d3d | 2017-06-04 12:11:05 -0700 | [diff] [blame] | 10 | use self::walkdir::DirEntry; |
| 11 | |
David Tolnay | ecd024d | 2018-07-21 09:07:56 -0700 | [diff] [blame] | 12 | pub mod eq; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 13 | pub mod parse; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 14 | |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 15 | /// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it. |
David Tolnay | ee97dbf | 2017-11-19 14:24:38 -0800 | [diff] [blame] | 16 | pub 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 Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 20 | } |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | pub 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 Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 38 | if path_string.starts_with("tests/rust/src/test/parse-fail") |
| 39 | || path_string.starts_with("tests/rust/src/test/compile-fail") |
David Tolnay | d7c5d02 | 2018-07-21 14:32:55 -0700 | [diff] [blame] | 40 | || path_string.starts_with("tests/rust/src/test/rustfix") |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 41 | { |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 42 | 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 Tolnay | d7c5d02 | 2018-07-21 14:32:55 -0700 | [diff] [blame] | 54 | // 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 Tolnay | 13b6a13 | 2018-03-31 20:38:58 +0200 | [diff] [blame] | 57 | // not actually test cases |
David Tolnay | 54a8fee | 2018-10-27 22:48:31 -0700 | [diff] [blame] | 58 | "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 Tolnay | e9ceb54 | 2018-08-21 21:04:33 -0400 | [diff] [blame] | 60 | "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false, |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 61 | _ => true, |
| 62 | } |
| 63 | } |
| 64 | |
Alex Crichton | 8637477 | 2017-07-07 20:39:28 -0700 | [diff] [blame] | 65 | pub fn clone_rust() { |
David Tolnay | ed8716e | 2017-12-25 21:49:39 -0500 | [diff] [blame] | 66 | let result = Command::new("tests/clone.sh").status().unwrap(); |
Alex Crichton | 8637477 | 2017-07-07 20:39:28 -0700 | [diff] [blame] | 67 | println!("result: {}", result); |
| 68 | assert!(result.success()); |
| 69 | } |