blob: e7fbf4c6e4d8ef9bd3f734fc1f032a643fcad369 [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
Michael Layzell53fc31a2017-06-07 09:21:53 -040023/// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it.
David Tolnayee97dbf2017-11-19 14:24:38 -080024pub fn abort_after() -> usize {
25 match env::var("ABORT_AFTER_FAILURE") {
26 Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"),
27 Err(_) => std::usize::MAX,
Michael Layzell53fc31a2017-06-07 09:21:53 -040028 }
Michael Layzell53fc31a2017-06-07 09:21:53 -040029}
30
31pub fn base_dir_filter(entry: &DirEntry) -> bool {
32 let path = entry.path();
33 if path.is_dir() {
34 return true; // otherwise walkdir does not visit the files
35 }
36 if path.extension().map(|e| e != "rs").unwrap_or(true) {
37 return false;
38 }
39 let path_string = path.to_string_lossy();
40 let path_string = if cfg!(windows) {
41 path_string.replace('\\', "/").into()
42 } else {
43 path_string
44 };
45 // TODO assert that parsing fails on the parse-fail cases
David Tolnay51382052017-12-27 13:46:21 -050046 if path_string.starts_with("tests/rust/src/test/parse-fail")
47 || path_string.starts_with("tests/rust/src/test/compile-fail")
David Tolnayd7c5d022018-07-21 14:32:55 -070048 || path_string.starts_with("tests/rust/src/test/rustfix")
David Tolnay51382052017-12-27 13:46:21 -050049 {
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() {
David Tolnayd7c5d022018-07-21 14:32:55 -070062 // Deprecated placement syntax
63 "tests/rust/src/test/run-pass/new-box-syntax.rs" |
64 "tests/rust/src/test/ui/obsolete-in-place/bad.rs" |
David Tolnay13b6a132018-03-31 20:38:58 +020065 // not actually test cases
David Tolnay54a8fee2018-10-27 22:48:31 -070066 "tests/rust/src/test/run-pass/macros/auxiliary/macro-comma-support.rs" |
67 "tests/rust/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs" |
David Tolnaye9ceb542018-08-21 21:04:33 -040068 "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false,
Michael Layzell53fc31a2017-06-07 09:21:53 -040069 _ => true,
70 }
71}
72
Alex Crichton86374772017-07-07 20:39:28 -070073pub fn clone_rust() {
David Tolnayed8716e2017-12-25 21:49:39 -050074 let result = Command::new("tests/clone.sh").status().unwrap();
Alex Crichton86374772017-07-07 20:39:28 -070075 println!("result: {}", result);
76 assert!(result.success());
77}