diff options
Diffstat (limited to 'crates/ra_syntax/tests/test.rs')
-rw-r--r-- | crates/ra_syntax/tests/test.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/ra_syntax/tests/test.rs b/crates/ra_syntax/tests/test.rs index a07855768..c17b6ffa6 100644 --- a/crates/ra_syntax/tests/test.rs +++ b/crates/ra_syntax/tests/test.rs | |||
@@ -41,8 +41,10 @@ fn parser_fuzz_tests() { | |||
41 | /// TODO: Use this as a benchmark | 41 | /// TODO: Use this as a benchmark |
42 | #[test] | 42 | #[test] |
43 | fn self_hosting_parsing() { | 43 | fn self_hosting_parsing() { |
44 | use std::ffi::OsStr; | ||
44 | let empty_vec = vec![]; | 45 | let empty_vec = vec![]; |
45 | let dir = project_dir(); | 46 | let dir = project_dir().join("crates"); |
47 | let mut count = 0; | ||
46 | for entry in walkdir::WalkDir::new(dir) | 48 | for entry in walkdir::WalkDir::new(dir) |
47 | .into_iter() | 49 | .into_iter() |
48 | .filter_entry(|entry| { | 50 | .filter_entry(|entry| { |
@@ -52,17 +54,16 @@ fn self_hosting_parsing() { | |||
52 | // TODO: this more neatly | 54 | // TODO: this more neatly |
53 | .any(|component| { | 55 | .any(|component| { |
54 | // Get all files which are not in the crates/ra_syntax/tests/data folder | 56 | // Get all files which are not in the crates/ra_syntax/tests/data folder |
55 | (component == Component::Normal(std::ffi::OsStr::new("data")) | 57 | component == Component::Normal(OsStr::new("data")) |
56 | // or the .git folder | ||
57 | || component == Component::Normal(std::ffi::OsStr::new(".git"))) | ||
58 | }) | 58 | }) |
59 | }) | 59 | }) |
60 | .map(|e| e.unwrap()) | 60 | .map(|e| e.unwrap()) |
61 | .filter(|entry| { | 61 | .filter(|entry| { |
62 | // Get all `.rs ` files | 62 | // Get all `.rs ` files |
63 | !entry.path().is_dir() && (entry.path().extension() == Some(std::ffi::OsStr::new("rs"))) | 63 | !entry.path().is_dir() && (entry.path().extension() == Some(OsStr::new("rs"))) |
64 | }) | 64 | }) |
65 | { | 65 | { |
66 | count += 1; | ||
66 | let text = read_text(entry.path()); | 67 | let text = read_text(entry.path()); |
67 | let node = SourceFileNode::parse(&text); | 68 | let node = SourceFileNode::parse(&text); |
68 | let errors = node.errors(); | 69 | let errors = node.errors(); |
@@ -72,6 +73,10 @@ fn self_hosting_parsing() { | |||
72 | entry | 73 | entry |
73 | ); | 74 | ); |
74 | } | 75 | } |
76 | assert!( | ||
77 | count > 30, | ||
78 | "self_hosting_parsing found too few files - is it running in the right directory?" | ||
79 | ) | ||
75 | } | 80 | } |
76 | /// Read file and normalize newlines. | 81 | /// Read file and normalize newlines. |
77 | /// | 82 | /// |