aboutsummaryrefslogtreecommitdiff
path: root/tools/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/main.rs')
-rw-r--r--tools/src/main.rs34
1 files changed, 24 insertions, 10 deletions
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;
3extern crate failure; 3extern crate failure;
4extern crate ron; 4extern crate ron;
5extern crate tera; 5extern crate tera;
6extern crate walkdir;
7extern crate tools; 6extern crate tools;
7extern crate walkdir;
8#[macro_use] 8#[macro_use]
9extern crate commandspec; 9extern crate commandspec;
10 10
11use std::{collections::{HashMap}, fs, path::{Path, PathBuf}};
12use clap::{App, Arg, SubCommand}; 11use clap::{App, Arg, SubCommand};
12use std::{
13 collections::HashMap,
14 fs,
15 path::{Path, PathBuf},
16};
13use tools::{collect_tests, Test}; 17use tools::{collect_tests, Test};
14 18
15type Result<T> = ::std::result::Result<T, failure::Error>; 19type Result<T> = ::std::result::Result<T, failure::Error>;
@@ -71,7 +75,8 @@ fn get_kinds() -> Result<String> {
71 tera.add_raw_template("grammar", &template) 75 tera.add_raw_template("grammar", &template)
72 .map_err(|e| format_err!("template error: {:?}", e))?; 76 .map_err(|e| format_err!("template error: {:?}", e))?;
73 tera.register_global_function("concat", Box::new(concat)); 77 tera.register_global_function("concat", Box::new(concat));
74 let ret = tera.render("grammar", &grammar) 78 let ret = tera
79 .render("grammar", &grammar)
75 .map_err(|e| format_err!("template error: {:?}", e))?; 80 .map_err(|e| format_err!("template error: {:?}", e))?;
76 return Ok(ret); 81 return Ok(ret);
77 82
@@ -157,7 +162,10 @@ fn existing_tests(dir: &Path) -> Result<HashMap<String, (PathBuf, Test)>> {
157 file_name[5..file_name.len() - 3].to_string() 162 file_name[5..file_name.len() - 3].to_string()
158 }; 163 };
159 let text = fs::read_to_string(&path)?; 164 let text = fs::read_to_string(&path)?;
160 let test = Test { name: name.clone(), text }; 165 let test = Test {
166 name: name.clone(),
167 text,
168 };
161 match res.insert(name, (path, test)) { 169 match res.insert(name, (path, test)) {
162 Some(old) => println!("Duplicate test: {:?}", old), 170 Some(old) => println!("Duplicate test: {:?}", old),
163 None => (), 171 None => (),
@@ -167,17 +175,23 @@ fn existing_tests(dir: &Path) -> Result<HashMap<String, (PathBuf, Test)>> {
167} 175}
168 176
169fn install_code_extension() -> Result<()> { 177fn install_code_extension() -> Result<()> {
170 execute!(r" 178 execute!(
179 r"
171cd code 180cd code
172npm install 181npm install
173 ")?; 182 "
174 execute!(r" 183 )?;
184 execute!(
185 r"
175cd code 186cd code
176./node_modules/vsce/out/vsce package 187./node_modules/vsce/out/vsce package
177 ")?; 188 "
178 execute!(r" 189 )?;
190 execute!(
191 r"
179cd code 192cd code
180code --install-extension ./libsyntax-rust-0.0.1.vsix 193code --install-extension ./libsyntax-rust-0.0.1.vsix
181 ")?; 194 "
195 )?;
182 Ok(()) 196 Ok(())
183} 197}