diff options
Diffstat (limited to 'crates/tools')
| -rw-r--r-- | crates/tools/src/main.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 7bd4a2d09..d2a6aa94f 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
| @@ -79,15 +79,21 @@ fn tests_from_dir(dir: &Path) -> Result<HashMap<String, Test>> { | |||
| 79 | if entry.path().extension().unwrap_or_default() != "rs" { | 79 | if entry.path().extension().unwrap_or_default() != "rs" { |
| 80 | continue; | 80 | continue; |
| 81 | } | 81 | } |
| 82 | let text = fs::read_to_string(entry.path())?; | 82 | process_file(&mut res, entry.path())?; |
| 83 | } | ||
| 84 | let grammar_rs = dir.parent().unwrap().join("grammar.rs"); | ||
| 85 | process_file(&mut res, &grammar_rs)?; | ||
| 86 | return Ok(res); | ||
| 87 | fn process_file(res: &mut HashMap<String, Test>, path: &Path) -> Result<()> { | ||
| 88 | let text = fs::read_to_string(path)?; | ||
| 83 | 89 | ||
| 84 | for (_, test) in collect_tests(&text) { | 90 | for (_, test) in collect_tests(&text) { |
| 85 | if let Some(old_test) = res.insert(test.name.clone(), test) { | 91 | if let Some(old_test) = res.insert(test.name.clone(), test) { |
| 86 | bail!("Duplicate test: {}", old_test.name) | 92 | bail!("Duplicate test: {}", old_test.name) |
| 87 | } | 93 | } |
| 88 | } | 94 | } |
| 95 | Ok(()) | ||
| 89 | } | 96 | } |
| 90 | Ok(res) | ||
| 91 | } | 97 | } |
| 92 | 98 | ||
| 93 | fn existing_tests(dir: &Path) -> Result<HashMap<String, (PathBuf, Test)>> { | 99 | fn existing_tests(dir: &Path) -> Result<HashMap<String, (PathBuf, Test)>> { |
