From 5633829a1684fb622d44d1aeb3baede4e7c0ff26 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Aug 2019 11:05:49 +0300 Subject: drop tera dependency --- crates/ra_tools/Cargo.toml | 1 - crates/ra_tools/src/lib.rs | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/ra_tools/Cargo.toml b/crates/ra_tools/Cargo.toml index a40a452aa..4c9aa1cc3 100644 --- a/crates/ra_tools/Cargo.toml +++ b/crates/ra_tools/Cargo.toml @@ -6,7 +6,6 @@ authors = ["rust-analyzer developers"] publish = false [dependencies] -teraron = "0.1.0" walkdir = "2.1.3" itertools = "0.8.0" clap = "2.32.0" diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs index de8c472d1..c02dee953 100644 --- a/crates/ra_tools/src/lib.rs +++ b/crates/ra_tools/src/lib.rs @@ -11,8 +11,6 @@ use std::{ use itertools::Itertools; -pub use teraron::{Mode, Overwrite, Verify}; - pub use self::codegen::generate; pub type Result = std::result::Result>; @@ -26,6 +24,13 @@ pub const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs.te pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs"; const TOOLCHAIN: &str = "stable"; +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum Mode { + Overwrite, + Verify, +} +pub use Mode::*; + #[derive(Debug)] pub struct Test { pub name: String, @@ -222,7 +227,7 @@ pub fn gen_tests(mode: Mode) -> Result<()> { tests_dir.join(file_name) } }; - teraron::update(&path, &test.text, mode)?; + update(&path, &test.text, mode)?; } Ok(()) } @@ -306,3 +311,20 @@ fn existing_tests(dir: &Path, ok: bool) -> Result Result<()> { + match fs::read_to_string(path) { + Ok(ref old_contents) if old_contents == contents => { + return Ok(()); + } + _ => (), + } + if mode == Verify { + Err(format!("`{}` is not up-to-date", path.display()))?; + } + eprintln!("updating {}", path.display()); + fs::write(path, contents)?; + Ok(()) +} -- cgit v1.2.3