David Tolnay | 5553501 | 2018-01-05 16:39:23 -0800 | [diff] [blame] | 1 | // Copyright 2018 Syn Developers |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 4 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 5 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 6 | // option. This file may not be copied, modified, or distributed |
| 7 | // except according to those terms. |
| 8 | |
David Tolnay | c7a5d3d | 2017-06-04 12:11:05 -0700 | [diff] [blame] | 9 | #![allow(dead_code)] |
| 10 | |
Nika Layzell | a2a1a4a | 2017-11-19 11:33:17 -0500 | [diff] [blame] | 11 | extern crate syntax; |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 12 | extern crate walkdir; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 13 | |
David Tolnay | ee97dbf | 2017-11-19 14:24:38 -0800 | [diff] [blame] | 14 | use std; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 15 | use std::env; |
Alex Crichton | 8637477 | 2017-07-07 20:39:28 -0700 | [diff] [blame] | 16 | use std::process::Command; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 17 | |
David Tolnay | c7a5d3d | 2017-06-04 12:11:05 -0700 | [diff] [blame] | 18 | use self::walkdir::DirEntry; |
| 19 | |
David Tolnay | ecd024d | 2018-07-21 09:07:56 -0700 | [diff] [blame] | 20 | pub mod eq; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 21 | pub mod parse; |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 22 | |
| 23 | pub fn check_min_stack() { |
Alex Crichton | 3fec393 | 2018-05-17 12:09:13 -0700 | [diff] [blame] | 24 | let min_stack_value = match env::var("RUST_MIN_STACK") { |
| 25 | Ok(s) => s, |
| 26 | Err(_) => { |
| 27 | env::set_var("RUST_MIN_STACK", 16000000.to_string()); |
David Tolnay | 65fb566 | 2018-05-20 20:02:28 -0700 | [diff] [blame] | 28 | return; |
Alex Crichton | 3fec393 | 2018-05-17 12:09:13 -0700 | [diff] [blame] | 29 | } |
| 30 | }; |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 31 | let min_stack_value: usize = min_stack_value |
| 32 | .parse() |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 33 | .expect("RUST_MIN_STACK env var should be set since some tests require it."); |
David Tolnay | 3cede94 | 2017-12-26 12:29:24 -0500 | [diff] [blame] | 34 | assert!(min_stack_value >= 16_000_000); |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it. |
David Tolnay | ee97dbf | 2017-11-19 14:24:38 -0800 | [diff] [blame] | 38 | pub fn abort_after() -> usize { |
| 39 | match env::var("ABORT_AFTER_FAILURE") { |
| 40 | Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"), |
| 41 | Err(_) => std::usize::MAX, |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 42 | } |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | pub fn base_dir_filter(entry: &DirEntry) -> bool { |
| 46 | let path = entry.path(); |
| 47 | if path.is_dir() { |
| 48 | return true; // otherwise walkdir does not visit the files |
| 49 | } |
| 50 | if path.extension().map(|e| e != "rs").unwrap_or(true) { |
| 51 | return false; |
| 52 | } |
| 53 | let path_string = path.to_string_lossy(); |
| 54 | let path_string = if cfg!(windows) { |
| 55 | path_string.replace('\\', "/").into() |
| 56 | } else { |
| 57 | path_string |
| 58 | }; |
| 59 | // TODO assert that parsing fails on the parse-fail cases |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 60 | if path_string.starts_with("tests/rust/src/test/parse-fail") |
| 61 | || path_string.starts_with("tests/rust/src/test/compile-fail") |
David Tolnay | d7c5d02 | 2018-07-21 14:32:55 -0700 | [diff] [blame] | 62 | || path_string.starts_with("tests/rust/src/test/rustfix") |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 63 | { |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 64 | return false; |
| 65 | } |
| 66 | |
| 67 | if path_string.starts_with("tests/rust/src/test/ui") { |
| 68 | let stderr_path = path.with_extension("stderr"); |
| 69 | if stderr_path.exists() { |
| 70 | // Expected to fail in some way |
| 71 | return false; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | match path_string.as_ref() { |
David Tolnay | e9ceb54 | 2018-08-21 21:04:33 -0400 | [diff] [blame^] | 76 | // Existential type |
| 77 | "tests/rust/src/test/run-pass/existential_type.rs" | |
| 78 | "tests/rust/src/test/ui/existential_types/bound_reduction.rs" | |
| 79 | "tests/rust/src/test/ui/existential_types/different_defining_uses_never_type2.rs" | |
| 80 | "tests/rust/src/test/ui/existential_types/existential-associated-type.rs" | |
| 81 | "tests/rust/src/test/ui/existential_types/generic_lifetime_param.rs" | |
| 82 | "tests/rust/src/test/ui/impl-trait/associated-existential-type-generic-trait.rs" | |
| 83 | "tests/rust/src/test/ui/impl-trait/associated-existential-type-trivial.rs" | |
| 84 | "tests/rust/src/test/ui/impl-trait/associated-existential-type.rs" | |
| 85 | "tests/rust/src/test/ui/impl-trait/existential_type_in_fn_body.rs" | |
David Tolnay | d7c5d02 | 2018-07-21 14:32:55 -0700 | [diff] [blame] | 86 | // Deprecated placement syntax |
| 87 | "tests/rust/src/test/run-pass/new-box-syntax.rs" | |
| 88 | "tests/rust/src/test/ui/obsolete-in-place/bad.rs" | |
David Tolnay | 13b6a13 | 2018-03-31 20:38:58 +0200 | [diff] [blame] | 89 | // not actually test cases |
| 90 | "tests/rust/src/test/run-pass/auxiliary/macro-comma-support.rs" | |
David Tolnay | e9ceb54 | 2018-08-21 21:04:33 -0400 | [diff] [blame^] | 91 | "tests/rust/src/test/run-pass/auxiliary/macro-include-items-expr.rs" | |
| 92 | "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false, |
Michael Layzell | 53fc31a | 2017-06-07 09:21:53 -0400 | [diff] [blame] | 93 | _ => true, |
| 94 | } |
| 95 | } |
| 96 | |
Alex Crichton | 8637477 | 2017-07-07 20:39:28 -0700 | [diff] [blame] | 97 | pub fn clone_rust() { |
David Tolnay | ed8716e | 2017-12-25 21:49:39 -0500 | [diff] [blame] | 98 | let result = Command::new("tests/clone.sh").status().unwrap(); |
Alex Crichton | 8637477 | 2017-07-07 20:39:28 -0700 | [diff] [blame] | 99 | println!("result: {}", result); |
| 100 | assert!(result.success()); |
| 101 | } |