diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-08 18:52:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-08 18:52:08 +0000 |
commit | 8b7e82b012c417ec40a896203ad79f20cf5530ef (patch) | |
tree | 85413766cc45708d77dfa9cb5a3a00767af8461a /xtask/src/codegen/gen_parser_tests.rs | |
parent | 071dde1c1da10e3580bded99dc2d529074356536 (diff) | |
parent | d2bb2268d3a9cc0e2a6970c85c45724af5eb255c (diff) |
Merge #7918
7918: Generalize file ensuring infrastructure r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'xtask/src/codegen/gen_parser_tests.rs')
-rw-r--r-- | xtask/src/codegen/gen_parser_tests.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/xtask/src/codegen/gen_parser_tests.rs b/xtask/src/codegen/gen_parser_tests.rs index cb8939063..096590653 100644 --- a/xtask/src/codegen/gen_parser_tests.rs +++ b/xtask/src/codegen/gen_parser_tests.rs | |||
@@ -8,13 +8,13 @@ use std::{ | |||
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | codegen::{extract_comment_blocks, update, Mode}, | 11 | codegen::{ensure_file_contents, extract_comment_blocks}, |
12 | project_root, Result, | 12 | project_root, Result, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | pub(crate) fn generate_parser_tests(mode: Mode) -> Result<()> { | 15 | pub(crate) fn generate_parser_tests() -> Result<()> { |
16 | let tests = tests_from_dir(&project_root().join(Path::new("crates/parser/src/grammar")))?; | 16 | let tests = tests_from_dir(&project_root().join(Path::new("crates/parser/src/grammar")))?; |
17 | fn install_tests(tests: &HashMap<String, Test>, into: &str, mode: Mode) -> Result<()> { | 17 | fn install_tests(tests: &HashMap<String, Test>, into: &str) -> Result<()> { |
18 | let tests_dir = project_root().join(into); | 18 | let tests_dir = project_root().join(into); |
19 | if !tests_dir.is_dir() { | 19 | if !tests_dir.is_dir() { |
20 | fs::create_dir_all(&tests_dir)?; | 20 | fs::create_dir_all(&tests_dir)?; |
@@ -35,12 +35,12 @@ pub(crate) fn generate_parser_tests(mode: Mode) -> Result<()> { | |||
35 | tests_dir.join(file_name) | 35 | tests_dir.join(file_name) |
36 | } | 36 | } |
37 | }; | 37 | }; |
38 | update(&path, &test.text, mode)?; | 38 | ensure_file_contents(&path, &test.text)?; |
39 | } | 39 | } |
40 | Ok(()) | 40 | Ok(()) |
41 | } | 41 | } |
42 | install_tests(&tests.ok, "crates/syntax/test_data/parser/inline/ok", mode)?; | 42 | install_tests(&tests.ok, "crates/syntax/test_data/parser/inline/ok")?; |
43 | install_tests(&tests.err, "crates/syntax/test_data/parser/inline/err", mode) | 43 | install_tests(&tests.err, "crates/syntax/test_data/parser/inline/err") |
44 | } | 44 | } |
45 | 45 | ||
46 | #[derive(Debug)] | 46 | #[derive(Debug)] |