diff options
author | David Tolnay <dtolnay@gmail.com> | 2019-06-30 11:54:14 -0700 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2019-06-30 12:02:52 -0700 |
commit | 4d156fd9d664a1e4f44672fc7556f3d3c97136cc (patch) | |
tree | fd4198856ddccb5e7df113ae34836c5a284c6792 /tests | |
parent | 49a674c76e19c41a26210b47f72ddad1e425ff34 (diff) | |
download | syn-4d156fd9d664a1e4f44672fc7556f3d3c97136cc.tar.gz |
Module for rust-lang/rust repo related functions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common/mod.rs | 58 | ||||
-rw-r--r-- | tests/repo/mod.rs | 54 | ||||
-rw-r--r-- | tests/test_precedence.rs | 6 | ||||
-rw-r--r-- | tests/test_round_trip.rs | 6 |
4 files changed, 63 insertions, 61 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 84b317a4..8b784bee 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,13 +1,6 @@ #![allow(dead_code)] -extern crate syntax; -extern crate walkdir; - -use std; use std::env; -use std::process::Command; - -use self::walkdir::DirEntry; pub mod eq; pub mod parse; @@ -16,55 +9,6 @@ pub mod parse; pub fn abort_after() -> usize { match env::var("ABORT_AFTER_FAILURE") { Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"), - Err(_) => std::usize::MAX, - } -} - -pub fn base_dir_filter(entry: &DirEntry) -> bool { - let path = entry.path(); - if path.is_dir() { - return true; // otherwise walkdir does not visit the files - } - if path.extension().map(|e| e != "rs").unwrap_or(true) { - return false; - } - let path_string = path.to_string_lossy(); - let path_string = if cfg!(windows) { - path_string.replace('\\', "/").into() - } else { - path_string - }; - // TODO assert that parsing fails on the parse-fail cases - if path_string.starts_with("tests/rust/src/test/parse-fail") - || path_string.starts_with("tests/rust/src/test/compile-fail") - || path_string.starts_with("tests/rust/src/test/rustfix") - { - return false; + Err(_) => usize::max_value(), } - - if path_string.starts_with("tests/rust/src/test/ui") { - let stderr_path = path.with_extension("stderr"); - if stderr_path.exists() { - // Expected to fail in some way - return false; - } - } - - match path_string.as_ref() { - // Deprecated placement syntax - "tests/rust/src/test/run-pass/new-box-syntax.rs" | - "tests/rust/src/test/ui/obsolete-in-place/bad.rs" | - // 2015-style dyn that libsyntax rejects - "tests/rust/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs" | - // not actually test cases - "tests/rust/src/test/run-pass/macros/auxiliary/macro-comma-support.rs" | - "tests/rust/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs" | - "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false, - _ => true, - } -} - -pub fn clone_rust() { - let result = Command::new("tests/clone.sh").status().unwrap(); - assert!(result.success()); } diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs new file mode 100644 index 00000000..6247bdb3 --- /dev/null +++ b/tests/repo/mod.rs @@ -0,0 +1,54 @@ +extern crate walkdir; + +use std::process::Command; + +use self::walkdir::DirEntry; + +pub fn base_dir_filter(entry: &DirEntry) -> bool { + let path = entry.path(); + if path.is_dir() { + return true; // otherwise walkdir does not visit the files + } + if path.extension().map(|e| e != "rs").unwrap_or(true) { + return false; + } + let path_string = path.to_string_lossy(); + let path_string = if cfg!(windows) { + path_string.replace('\\', "/").into() + } else { + path_string + }; + // TODO assert that parsing fails on the parse-fail cases + if path_string.starts_with("tests/rust/src/test/parse-fail") + || path_string.starts_with("tests/rust/src/test/compile-fail") + || path_string.starts_with("tests/rust/src/test/rustfix") + { + return false; + } + + if path_string.starts_with("tests/rust/src/test/ui") { + let stderr_path = path.with_extension("stderr"); + if stderr_path.exists() { + // Expected to fail in some way + return false; + } + } + + match path_string.as_ref() { + // Deprecated placement syntax + "tests/rust/src/test/run-pass/new-box-syntax.rs" | + "tests/rust/src/test/ui/obsolete-in-place/bad.rs" | + // 2015-style dyn that libsyntax rejects + "tests/rust/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs" | + // not actually test cases + "tests/rust/src/test/run-pass/macros/auxiliary/macro-comma-support.rs" | + "tests/rust/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs" | + "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false, + _ => true, + } +} + +pub fn clone_rust() { + let result = Command::new("tests/clone.sh").status().unwrap(); + assert!(result.success()); +} diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs index 30de381c..4774c284 100644 --- a/tests/test_precedence.rs +++ b/tests/test_precedence.rs @@ -49,6 +49,8 @@ mod macros; #[allow(dead_code)] mod common; +mod repo; + /// Test some pre-set expressions chosen by us. #[test] fn test_simple_precedence() { @@ -91,7 +93,7 @@ fn test_simple_precedence() { #[test] #[cfg_attr(target_os = "windows", ignore = "requires nix .sh")] fn test_rustc_precedence() { - common::clone_rust(); + repo::clone_rust(); let abort_after = common::abort_after(); if abort_after == 0 { panic!("Skipping all precedence tests"); @@ -106,7 +108,7 @@ fn test_rustc_precedence() { WalkDir::new("tests/rust") .sort_by(|a, b| a.file_name().cmp(b.file_name())) .into_iter() - .filter_entry(common::base_dir_filter) + .filter_entry(repo::base_dir_filter) .collect::<Result<Vec<DirEntry>, walkdir::Error>>() .unwrap() .into_par_iter() diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs index eeadd6cd..2fc9cecd 100644 --- a/tests/test_round_trip.rs +++ b/tests/test_round_trip.rs @@ -33,12 +33,14 @@ mod macros; #[allow(dead_code)] mod common; +mod repo; + use common::eq::SpanlessEq; #[test] #[cfg_attr(target_os = "windows", ignore = "requires nix .sh")] fn test_round_trip() { - common::clone_rust(); + repo::clone_rust(); let abort_after = common::abort_after(); if abort_after == 0 { panic!("Skipping all round_trip tests"); @@ -49,7 +51,7 @@ fn test_round_trip() { WalkDir::new("tests/rust") .sort_by(|a, b| a.file_name().cmp(b.file_name())) .into_iter() - .filter_entry(common::base_dir_filter) + .filter_entry(repo::base_dir_filter) .collect::<Result<Vec<DirEntry>, walkdir::Error>>() .unwrap() .into_par_iter() |