blob: 723fab42c06e4b080a98b15cf1acc679384917e7 [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
Michael Layzell53fc31a2017-06-07 09:21:53 -040012pub mod parse;
13pub mod respan;
14
15pub fn check_min_stack() {
16 let min_stack_value = env::var("RUST_MIN_STACK")
17 .expect("RUST_MIN_STACK env var should be set since some tests require it.");
David Tolnay51382052017-12-27 13:46:21 -050018 let min_stack_value: usize = min_stack_value
19 .parse()
Michael Layzell53fc31a2017-06-07 09:21:53 -040020 .expect("RUST_MIN_STACK env var should be set since some tests require it.");
David Tolnay3cede942017-12-26 12:29:24 -050021 assert!(min_stack_value >= 16_000_000);
Michael Layzell53fc31a2017-06-07 09:21:53 -040022}
23
24/// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it.
David Tolnayee97dbf2017-11-19 14:24:38 -080025pub fn abort_after() -> usize {
26 match env::var("ABORT_AFTER_FAILURE") {
27 Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"),
28 Err(_) => std::usize::MAX,
Michael Layzell53fc31a2017-06-07 09:21:53 -040029 }
Michael Layzell53fc31a2017-06-07 09:21:53 -040030}
31
32pub fn base_dir_filter(entry: &DirEntry) -> bool {
33 let path = entry.path();
34 if path.is_dir() {
35 return true; // otherwise walkdir does not visit the files
36 }
37 if path.extension().map(|e| e != "rs").unwrap_or(true) {
38 return false;
39 }
40 let path_string = path.to_string_lossy();
41 let path_string = if cfg!(windows) {
42 path_string.replace('\\', "/").into()
43 } else {
44 path_string
45 };
46 // TODO assert that parsing fails on the parse-fail cases
David Tolnay51382052017-12-27 13:46:21 -050047 if path_string.starts_with("tests/rust/src/test/parse-fail")
48 || path_string.starts_with("tests/rust/src/test/compile-fail")
49 {
Michael Layzell53fc31a2017-06-07 09:21:53 -040050 return false;
51 }
52
53 if path_string.starts_with("tests/rust/src/test/ui") {
54 let stderr_path = path.with_extension("stderr");
55 if stderr_path.exists() {
56 // Expected to fail in some way
57 return false;
58 }
59 }
60
61 match path_string.as_ref() {
62 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070063 //
64 // let a = A { #[a] b: c };
Michael Layzell53fc31a2017-06-07 09:21:53 -040065 "tests/rust/src/librustc_data_structures/blake2b.rs" |
66 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070067 //
68 // enum A { B = #[a] 2 }
Michael Layzell53fc31a2017-06-07 09:21:53 -040069 "tests/rust/src/test/incremental/hashes/enum_defs.rs" |
70 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070071 //
72 // { #![foo] }
Michael Layzell53fc31a2017-06-07 09:21:53 -040073 "tests/rust/src/test/pretty/stmt_expr_attributes.rs" |
Michael Layzell53fc31a2017-06-07 09:21:53 -040074 // TODO better support for attributes
75 "tests/rust/src/test/run-pass/cfg_stmt_expr.rs" |
76 // TODO weird glob import
Alex Crichton39567892017-08-28 09:55:44 -070077 //
78 // use ::*;
Michael Layzell53fc31a2017-06-07 09:21:53 -040079 "tests/rust/src/test/run-pass/import-glob-crate.rs" |
80 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070081 //
82 // impl Foo { #![a] }
Michael Layzell53fc31a2017-06-07 09:21:53 -040083 "tests/rust/src/test/run-pass/inner-attrs-on-impl.rs" |
84 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070085 "tests/rust/src/test/run-pass/item-attributes.rs" |
Alex Crichtone21116f2017-08-28 09:56:12 -070086 // TODO support lifetimes before traits
87 //
88 // Box<'foo + Bar>
89 "tests/rust/src/test/run-pass/trait-object-lifetime-first.rs" |
David Tolnayb0d21412017-12-19 21:11:47 -080090 // TODO feature(use_nested_groups)
91 //
92 // use a::{B, D::{self, *, g::H}};
93 "tests/rust/src/test/run-pass/use-nested-groups.rs" |
David Tolnay8701a5c2017-12-28 23:31:10 -050094 // Deprecated placement syntax
95 "tests/rust/src/test/run-pass/new-box-syntax.rs" |
96 // Deprecated placement syntax
97 "tests/rust/src/test/run-pass/placement-in-syntax.rs" |
Alex Crichton39567892017-08-28 09:55:44 -070098 // not actually a test case
99 "tests/rust/src/test/run-pass/auxiliary/macro-include-items-expr.rs" => false,
Michael Layzell53fc31a2017-06-07 09:21:53 -0400100 _ => true,
101 }
102}
103
Alex Crichton86374772017-07-07 20:39:28 -0700104pub fn clone_rust() {
David Tolnayed8716e2017-12-25 21:49:39 -0500105 let result = Command::new("tests/clone.sh").status().unwrap();
Alex Crichton86374772017-07-07 20:39:28 -0700106 println!("result: {}", result);
107 assert!(result.success());
108}