diff options
Diffstat (limited to 'tools/src/main.rs')
-rw-r--r-- | tools/src/main.rs | 34 |
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; | |||
3 | extern crate failure; | 3 | extern crate failure; |
4 | extern crate ron; | 4 | extern crate ron; |
5 | extern crate tera; | 5 | extern crate tera; |
6 | extern crate walkdir; | ||
7 | extern crate tools; | 6 | extern crate tools; |
7 | extern crate walkdir; | ||
8 | #[macro_use] | 8 | #[macro_use] |
9 | extern crate commandspec; | 9 | extern crate commandspec; |
10 | 10 | ||
11 | use std::{collections::{HashMap}, fs, path::{Path, PathBuf}}; | ||
12 | use clap::{App, Arg, SubCommand}; | 11 | use clap::{App, Arg, SubCommand}; |
12 | use std::{ | ||
13 | collections::HashMap, | ||
14 | fs, | ||
15 | path::{Path, PathBuf}, | ||
16 | }; | ||
13 | use tools::{collect_tests, Test}; | 17 | use tools::{collect_tests, Test}; |
14 | 18 | ||
15 | type Result<T> = ::std::result::Result<T, failure::Error>; | 19 | type 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 | ||
169 | fn install_code_extension() -> Result<()> { | 177 | fn install_code_extension() -> Result<()> { |
170 | execute!(r" | 178 | execute!( |
179 | r" | ||
171 | cd code | 180 | cd code |
172 | npm install | 181 | npm install |
173 | ")?; | 182 | " |
174 | execute!(r" | 183 | )?; |
184 | execute!( | ||
185 | r" | ||
175 | cd code | 186 | cd 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" | ||
179 | cd code | 192 | cd code |
180 | code --install-extension ./libsyntax-rust-0.0.1.vsix | 193 | code --install-extension ./libsyntax-rust-0.0.1.vsix |
181 | ")?; | 194 | " |
195 | )?; | ||
182 | Ok(()) | 196 | Ok(()) |
183 | } | 197 | } |