From 9d9e637ef39cbc00eaebad93294a60ccfd3405eb Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Tue, 16 Oct 2018 00:54:27 +0600 Subject: Refactor the constants --- crates/tools/tests/cli.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'crates/tools/tests') diff --git a/crates/tools/tests/cli.rs b/crates/tools/tests/cli.rs index 9ff1eecd9..d0ed60f7a 100644 --- a/crates/tools/tests/cli.rs +++ b/crates/tools/tests/cli.rs @@ -1,19 +1,13 @@ extern crate tools; -use std::path::Path; -use tools::{render_template, update}; - -const SYNTAX_KINDS: &str = "../ra_syntax/src/syntax_kinds/generated.rs"; -const SYNTAX_KINDS_TEMPLATE: &str = "../ra_syntax/src/syntax_kinds/generated.rs.tera"; -const AST: &str = "../ra_syntax/src/ast/generated.rs"; -const AST_TEMPLATE: &str = "../ra_syntax/src/ast/generated.rs.tera"; +use tools::{AST, AST_TEMPLATE, SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE, render_template, update, project_root}; #[test] fn verify_template_generation() { - if let Err(error) = update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE).unwrap(), true) { + if let Err(error) = update(&project_root().join(SYNTAX_KINDS), &render_template(project_root().join(SYNTAX_KINDS_TEMPLATE)).unwrap(), true) { panic!("{}. Please update it by running `cargo gen-kinds`", error); } - if let Err(error) = update(Path::new(AST), &render_template(AST_TEMPLATE).unwrap(), true) { + if let Err(error) = update(&project_root().join(AST), &render_template(project_root().join(AST_TEMPLATE)).unwrap(), true) { panic!("{}. Please update it by running `cargo gen-kinds`", error); } } -- cgit v1.2.3