From 33b378797c33bf29af4104e0b11c31252451df0c Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Sun, 14 Oct 2018 20:58:53 +0600 Subject: Show how to generate code with error message --- crates/tools/src/lib.rs | 2 +- crates/tools/src/main.rs | 4 +--- crates/tools/tests/cli.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'crates') 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::{ use itertools::Itertools; use heck::{CamelCase, ShoutySnakeCase, SnakeCase}; -type Result = ::std::result::Result; +pub type Result = ::std::result::Result; #[derive(Debug)] 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::{ path::{Path, PathBuf}, process::Command, }; -use tools::{Test, collect_tests, render_template, update}; - -type Result = ::std::result::Result; +use tools::{Test, collect_tests, render_template, update, Result}; const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; 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"; #[test] fn verify_template_generation() { - update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR).unwrap(), true).unwrap(); - update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR).unwrap(), true).unwrap(); + if let Err(error) = update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR).unwrap(), true) { + panic!("{}. Please update it by running `cargo gen-kinds`", error); + } + if let Err(error) = update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR).unwrap(), true) { + panic!("{}. Please update it by running `cargo gen-kinds`", error); + } } \ No newline at end of file -- cgit v1.2.3