diff options
author | Muhammad Mominul Huque <[email protected]> | 2018-10-14 15:58:53 +0100 |
---|---|---|
committer | Muhammad Mominul Huque <[email protected]> | 2018-10-14 15:58:53 +0100 |
commit | 33b378797c33bf29af4104e0b11c31252451df0c (patch) | |
tree | be2b173bf617e6c6d123d0b1053a98ae270def73 /crates | |
parent | 114e9a2d74f1fa43c3418f8cd978fd4186fcb78b (diff) |
Show how to generate code with error message
Diffstat (limited to 'crates')
-rw-r--r-- | crates/tools/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/tools/src/main.rs | 4 | ||||
-rw-r--r-- | crates/tools/tests/cli.rs | 8 |
3 files changed, 8 insertions, 6 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index 352f4d135..7b5a60847 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs | |||
@@ -13,7 +13,7 @@ use std::{ | |||
13 | use itertools::Itertools; | 13 | use itertools::Itertools; |
14 | use heck::{CamelCase, ShoutySnakeCase, SnakeCase}; | 14 | use heck::{CamelCase, ShoutySnakeCase, SnakeCase}; |
15 | 15 | ||
16 | type Result<T> = ::std::result::Result<T, failure::Error>; | 16 | pub type Result<T> = ::std::result::Result<T, failure::Error>; |
17 | 17 | ||
18 | #[derive(Debug)] | 18 | #[derive(Debug)] |
19 | pub struct Test { | 19 | pub struct Test { |
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index cf5e662b0..179c1163f 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
@@ -11,9 +11,7 @@ use std::{ | |||
11 | path::{Path, PathBuf}, | 11 | path::{Path, PathBuf}, |
12 | process::Command, | 12 | process::Command, |
13 | }; | 13 | }; |
14 | use tools::{Test, collect_tests, render_template, update}; | 14 | use tools::{Test, collect_tests, render_template, update, Result}; |
15 | |||
16 | type Result<T> = ::std::result::Result<T, failure::Error>; | ||
17 | 15 | ||
18 | const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; | 16 | const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; |
19 | const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; | 17 | const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; |
diff --git a/crates/tools/tests/cli.rs b/crates/tools/tests/cli.rs index 26d9a991c..4d5b03b65 100644 --- a/crates/tools/tests/cli.rs +++ b/crates/tools/tests/cli.rs | |||
@@ -11,6 +11,10 @@ const AST_TEMPLATE: &str = "../ra_syntax/src/ast/generated.rs.tera"; | |||
11 | 11 | ||
12 | #[test] | 12 | #[test] |
13 | fn verify_template_generation() { | 13 | fn verify_template_generation() { |
14 | update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR).unwrap(), true).unwrap(); | 14 | if let Err(error) = update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR).unwrap(), true) { |
15 | update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR).unwrap(), true).unwrap(); | 15 | panic!("{}. Please update it by running `cargo gen-kinds`", error); |
16 | } | ||
17 | if let Err(error) = update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR).unwrap(), true) { | ||
18 | panic!("{}. Please update it by running `cargo gen-kinds`", error); | ||
19 | } | ||
16 | } \ No newline at end of file | 20 | } \ No newline at end of file |