blob: 99ee86ec23b3d4f825069dc64803769492e8830d [file] [log] [blame]
David Tolnay55535012018-01-05 16:39:23 -08001// 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 Tolnayc7a5d3d2017-06-04 12:11:05 -07009#![allow(dead_code)]
10
Nika Layzella2a1a4a2017-11-19 11:33:17 -050011extern crate syntax;
David Tolnay51382052017-12-27 13:46:21 -050012extern crate walkdir;
Michael Layzell53fc31a2017-06-07 09:21:53 -040013
David Tolnayee97dbf2017-11-19 14:24:38 -080014use std;
Michael Layzell53fc31a2017-06-07 09:21:53 -040015use std::env;
Alex Crichton86374772017-07-07 20:39:28 -070016use std::process::Command;
Michael Layzell53fc31a2017-06-07 09:21:53 -040017
David Tolnayc7a5d3d2017-06-04 12:11:05 -070018use self::walkdir::DirEntry;
19
David Tolnayecd024d2018-07-21 09:07:56 -070020pub mod eq;
Michael Layzell53fc31a2017-06-07 09:21:53 -040021pub mod parse;
Michael Layzell53fc31a2017-06-07 09:21:53 -040022
23pub fn check_min_stack() {
Alex Crichton3fec3932018-05-17 12:09:13 -070024 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 Tolnay65fb5662018-05-20 20:02:28 -070028 return;
Alex Crichton3fec3932018-05-17 12:09:13 -070029 }
30 };
David Tolnay51382052017-12-27 13:46:21 -050031 let min_stack_value: usize = min_stack_value
32 .parse()
Michael Layzell53fc31a2017-06-07 09:21:53 -040033 .expect("RUST_MIN_STACK env var should be set since some tests require it.");
David Tolnay3cede942017-12-26 12:29:24 -050034 assert!(min_stack_value >= 16_000_000);
Michael Layzell53fc31a2017-06-07 09:21:53 -040035}
36
37/// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it.
David Tolnayee97dbf2017-11-19 14:24:38 -080038pub 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 Layzell53fc31a2017-06-07 09:21:53 -040042 }
Michael Layzell53fc31a2017-06-07 09:21:53 -040043}
44
45pub 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 Tolnay51382052017-12-27 13:46:21 -050060 if path_string.starts_with("tests/rust/src/test/parse-fail")
61 || path_string.starts_with("tests/rust/src/test/compile-fail")
62 {
Michael Layzell53fc31a2017-06-07 09:21:53 -040063 return false;
64 }
65
66 if path_string.starts_with("tests/rust/src/test/ui") {
67 let stderr_path = path.with_extension("stderr");
68 if stderr_path.exists() {
69 // Expected to fail in some way
70 return false;
71 }
72 }
73
74 match path_string.as_ref() {
75 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070076 //
Alex Crichton39567892017-08-28 09:55:44 -070077 // { #![foo] }
Michael Layzell53fc31a2017-06-07 09:21:53 -040078 "tests/rust/src/test/pretty/stmt_expr_attributes.rs" |
Michael Layzell53fc31a2017-06-07 09:21:53 -040079 // TODO better support for attributes
80 "tests/rust/src/test/run-pass/cfg_stmt_expr.rs" |
Michael Layzell53fc31a2017-06-07 09:21:53 -040081 // TODO better support for attributes
Alex Crichton39567892017-08-28 09:55:44 -070082 "tests/rust/src/test/run-pass/item-attributes.rs" |
David Tolnay8701a5c2017-12-28 23:31:10 -050083 // Deprecated placement syntax
84 "tests/rust/src/test/run-pass/new-box-syntax.rs" |
85 // Deprecated placement syntax
86 "tests/rust/src/test/run-pass/placement-in-syntax.rs" |
David Tolnay1208dce2018-03-31 22:50:09 +020087 // TODO inclusive range syntax
88 "tests/rust/src/test/run-pass/range-inclusive-pattern-precedence.rs" |
David Tolnay5dec63d2018-01-18 23:36:12 -080089 // TODO feature(extern_in_paths)
90 //
91 // use extern::xcrate;
92 "tests/rust/src/test/run-pass/rfc-2126-extern-absolute-paths/extern.rs" |
David Tolnaya27f29f2018-07-21 13:24:58 -070093 // TODO
94 "tests/rust/src/libcore/ascii.rs" |
95 "tests/rust/src/libcore/char/decode.rs" |
96 "tests/rust/src/libcore/char/methods.rs" |
97 "tests/rust/src/libcore/str/lossy.rs" |
98 "tests/rust/src/libcore/str/mod.rs" |
99 "tests/rust/src/librustc_apfloat/ieee.rs" |
100 "tests/rust/src/librustc_codegen_utils/symbol_names.rs" |
101 "tests/rust/src/librustc_mir/hair/pattern/check_match.rs" |
102 "tests/rust/src/librustc_target/abi/call/mod.rs" |
103 "tests/rust/src/librustc_target/abi/mod.rs" |
104 "tests/rust/src/libserialize/hex.rs" |
105 "tests/rust/src/libserialize/json.rs" |
106 "tests/rust/src/libstd/sys_common/backtrace.rs" |
107 "tests/rust/src/libstd/sys_common/wtf8.rs" |
108 "tests/rust/src/libsyntax/parse/lexer/mod.rs" |
109 "tests/rust/src/libsyntax_ext/format_foreign.rs" |
110 "tests/rust/src/libsyntax_pos/lib.rs" |
111 "tests/rust/src/libterm/terminfo/parm.rs" |
112 "tests/rust/src/test/run-make-fulldeps/save-analysis-rfc2126/extern_in_paths.rs" |
113 "tests/rust/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs" |
114 "tests/rust/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs" |
115 "tests/rust/src/test/run-pass/async-await.rs" |
116 "tests/rust/src/test/run-pass/byte-literals.rs" |
117 "tests/rust/src/test/run-pass/inferred-suffix-in-pattern-range.rs" |
118 "tests/rust/src/test/run-pass/issue-13867.rs" |
119 "tests/rust/src/test/run-pass/issue-18464.rs" |
120 "tests/rust/src/test/run-pass/issue-21475.rs" |
121 "tests/rust/src/test/run-pass/issue-26251.rs" |
122 "tests/rust/src/test/run-pass/issue-35423.rs" |
123 "tests/rust/src/test/run-pass/issue-49632.rs" |
124 "tests/rust/src/test/run-pass/issue-7222.rs" |
125 "tests/rust/src/test/run-pass/label_break_value.rs" |
126 "tests/rust/src/test/run-pass/macros-in-extern.rs" |
127 "tests/rust/src/test/run-pass/match-range-infer.rs" |
128 "tests/rust/src/test/run-pass/match-range-static.rs" |
129 "tests/rust/src/test/run-pass/match-range.rs" |
130 "tests/rust/src/test/run-pass/rfc-2005-default-binding-mode/range.rs" |
131 "tests/rust/src/test/run-pass/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs" |
132 "tests/rust/src/test/rustfix/missing-comma-in-match.rs" |
133 "tests/rust/src/test/rustfix/str-as-char.rs" |
134 "tests/rust/src/test/rustfix/tuple-float-index.rs" |
135 "tests/rust/src/test/ui/const-eval/const_signed_pat.rs" |
136 "tests/rust/src/test/ui/obsolete-in-place/bad.rs" |
137 "tests/rust/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs" |
David Tolnay13b6a132018-03-31 20:38:58 +0200138 // not actually test cases
139 "tests/rust/src/test/run-pass/auxiliary/macro-comma-support.rs" |
Alex Crichton39567892017-08-28 09:55:44 -0700140 "tests/rust/src/test/run-pass/auxiliary/macro-include-items-expr.rs" => false,
Michael Layzell53fc31a2017-06-07 09:21:53 -0400141 _ => true,
142 }
143}
144
Alex Crichton86374772017-07-07 20:39:28 -0700145pub fn clone_rust() {
David Tolnayed8716e2017-12-25 21:49:39 -0500146 let result = Command::new("tests/clone.sh").status().unwrap();
Alex Crichton86374772017-07-07 20:39:28 -0700147 println!("result: {}", result);
148 assert!(result.success());
149}