diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-08 17:55:17 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-08 17:55:17 +0000 |
commit | 51f669606cfbd29f3e9a3695810ead4124f49e84 (patch) | |
tree | 1f23b16e096c0eec8daacc31443905c987bbf979 /crates/tools | |
parent | 5ad7547ce2f469905992acff5f95e55d54eda714 (diff) | |
parent | 7a79cde107ec71abbc7c715e933f29f7a1fb2b95 (diff) |
Merge #263
263: New modules r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
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)>> { |