From 9ce7e8110254e8db476c96bce2eecb2d16983159 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 15:40:40 +0300 Subject: cleanups --- tools/src/lib.rs | 11 +++++------ tools/src/main.rs | 34 ++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 16 deletions(-) (limited to 'tools/src') diff --git a/tools/src/lib.rs b/tools/src/lib.rs index 21a9468bc..5a7d846ff 100644 --- a/tools/src/lib.rs +++ b/tools/src/lib.rs @@ -1,7 +1,7 @@ extern crate itertools; -use std::hash; use itertools::Itertools; +use std::hash; #[derive(Debug)] pub struct Test { @@ -28,18 +28,17 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> { match block.next() { Some((idx, line)) if line.starts_with("test ") => { break (idx, line["test ".len()..].to_string()) - }, + } Some(_) => (), None => continue 'outer, } }; let text: String = itertools::join( - block.map(|(_, line)| line) - .chain(::std::iter::once("")), - "\n" + block.map(|(_, line)| line).chain(::std::iter::once("")), + "\n", ); assert!(!text.trim().is_empty() && text.ends_with("\n")); - res.push((start_line, Test {name, text })) + res.push((start_line, Test { name, text })) } res } diff --git a/tools/src/main.rs b/tools/src/main.rs index 3acb6e7ed..7c6c7a1aa 100644 --- a/tools/src/main.rs +++ b/tools/src/main.rs @@ -3,13 +3,17 @@ extern crate clap; extern crate failure; extern crate ron; extern crate tera; -extern crate walkdir; extern crate tools; +extern crate walkdir; #[macro_use] extern crate commandspec; -use std::{collections::{HashMap}, fs, path::{Path, PathBuf}}; use clap::{App, Arg, SubCommand}; +use std::{ + collections::HashMap, + fs, + path::{Path, PathBuf}, +}; use tools::{collect_tests, Test}; type Result = ::std::result::Result; @@ -71,7 +75,8 @@ fn get_kinds() -> Result { tera.add_raw_template("grammar", &template) .map_err(|e| format_err!("template error: {:?}", e))?; tera.register_global_function("concat", Box::new(concat)); - let ret = tera.render("grammar", &grammar) + let ret = tera + .render("grammar", &grammar) .map_err(|e| format_err!("template error: {:?}", e))?; return Ok(ret); @@ -157,7 +162,10 @@ fn existing_tests(dir: &Path) -> Result> { file_name[5..file_name.len() - 3].to_string() }; let text = fs::read_to_string(&path)?; - let test = Test { name: name.clone(), text }; + let test = Test { + name: name.clone(), + text, + }; match res.insert(name, (path, test)) { Some(old) => println!("Duplicate test: {:?}", old), None => (), @@ -167,17 +175,23 @@ fn existing_tests(dir: &Path) -> Result> { } fn install_code_extension() -> Result<()> { - execute!(r" + execute!( + r" cd code npm install - ")?; - execute!(r" + " + )?; + execute!( + r" cd code ./node_modules/vsce/out/vsce package - ")?; - execute!(r" + " + )?; + execute!( + r" cd code code --install-extension ./libsyntax-rust-0.0.1.vsix - ")?; + " + )?; Ok(()) } -- cgit v1.2.3