diff options
Diffstat (limited to 'crates/tools')
-rw-r--r-- | crates/tools/src/lib.rs | 31 | ||||
-rw-r--r-- | crates/tools/src/main.rs | 8 | ||||
-rw-r--r-- | crates/tools/tests/cli.rs | 9 |
3 files changed, 24 insertions, 24 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index 29c46c7c4..3387d0620 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | extern crate itertools; | ||
2 | extern crate failure; | 1 | extern crate failure; |
2 | extern crate itertools; | ||
3 | extern crate teraron; | 3 | extern crate teraron; |
4 | 4 | ||
5 | use std::{ | 5 | use std::{ |
@@ -7,10 +7,10 @@ use std::{ | |||
7 | process::Command, | 7 | process::Command, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use itertools::Itertools; | ||
11 | use failure::bail; | 10 | use failure::bail; |
11 | use itertools::Itertools; | ||
12 | 12 | ||
13 | pub use teraron::{Mode, Verify, Overwrite}; | 13 | pub use teraron::{Mode, Overwrite, Verify}; |
14 | 14 | ||
15 | pub type Result<T> = ::std::result::Result<T, failure::Error>; | 15 | pub type Result<T> = ::std::result::Result<T, failure::Error>; |
16 | 16 | ||
@@ -63,16 +63,8 @@ pub fn generate(mode: Mode) -> Result<()> { | |||
63 | let grammar = project_root().join(GRAMMAR); | 63 | let grammar = project_root().join(GRAMMAR); |
64 | let syntax_kinds = project_root().join(SYNTAX_KINDS); | 64 | let syntax_kinds = project_root().join(SYNTAX_KINDS); |
65 | let ast = project_root().join(AST); | 65 | let ast = project_root().join(AST); |
66 | teraron::generate( | 66 | teraron::generate(&syntax_kinds, &grammar, mode)?; |
67 | &syntax_kinds, | 67 | teraron::generate(&ast, &grammar, mode)?; |
68 | &grammar, | ||
69 | mode, | ||
70 | )?; | ||
71 | teraron::generate( | ||
72 | &ast, | ||
73 | &grammar, | ||
74 | mode, | ||
75 | )?; | ||
76 | Ok(()) | 68 | Ok(()) |
77 | } | 69 | } |
78 | 70 | ||
@@ -101,9 +93,18 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> { | |||
101 | 93 | ||
102 | pub fn run_rustfmt(mode: Mode) -> Result<()> { | 94 | pub fn run_rustfmt(mode: Mode) -> Result<()> { |
103 | run(&format!("rustup install {}", TOOLCHAIN), ".")?; | 95 | run(&format!("rustup install {}", TOOLCHAIN), ".")?; |
104 | run(&format!("rustup component add rustfmt-preview --toolchain {}", TOOLCHAIN), ".")?; | 96 | run( |
97 | &format!( | ||
98 | "rustup component add rustfmt-preview --toolchain {}", | ||
99 | TOOLCHAIN | ||
100 | ), | ||
101 | ".", | ||
102 | )?; | ||
105 | if mode == Verify { | 103 | if mode == Verify { |
106 | run(&format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN), ".")?; | 104 | run( |
105 | &format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN), | ||
106 | ".", | ||
107 | )?; | ||
107 | } else { | 108 | } else { |
108 | run(&format!("rustup run {} -- cargo fmt", TOOLCHAIN), ".")?; | 109 | run(&format!("rustup run {} -- cargo fmt", TOOLCHAIN), ".")?; |
109 | } | 110 | } |
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 91675bbf0..dc623a464 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
@@ -1,19 +1,17 @@ | |||
1 | extern crate clap; | 1 | extern crate clap; |
2 | extern crate failure; | 2 | extern crate failure; |
3 | extern crate teraron; | ||
3 | extern crate tools; | 4 | extern crate tools; |
4 | extern crate walkdir; | 5 | extern crate walkdir; |
5 | extern crate teraron; | ||
6 | 6 | ||
7 | use clap::{App, Arg, SubCommand}; | 7 | use clap::{App, Arg, SubCommand}; |
8 | use failure::bail; | ||
8 | use std::{ | 9 | use std::{ |
9 | collections::HashMap, | 10 | collections::HashMap, |
10 | fs, | 11 | fs, |
11 | path::{Path, PathBuf}, | 12 | path::{Path, PathBuf}, |
12 | }; | 13 | }; |
13 | use tools::{ | 14 | use tools::{collect_tests, generate, run, run_rustfmt, Mode, Overwrite, Result, Test, Verify}; |
14 | collect_tests, Result, Test, generate, Mode, Overwrite, Verify, run, run_rustfmt, | ||
15 | }; | ||
16 | use failure::bail; | ||
17 | 15 | ||
18 | const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; | 16 | const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; |
19 | const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; | 17 | const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; |
diff --git a/crates/tools/tests/cli.rs b/crates/tools/tests/cli.rs index 8c53a8230..2d238d9ea 100644 --- a/crates/tools/tests/cli.rs +++ b/crates/tools/tests/cli.rs | |||
@@ -1,8 +1,6 @@ | |||
1 | extern crate tools; | 1 | extern crate tools; |
2 | 2 | ||
3 | use tools::{ | 3 | use tools::{generate, run_rustfmt, Verify}; |
4 | generate, Verify, run_rustfmt, | ||
5 | }; | ||
6 | 4 | ||
7 | #[test] | 5 | #[test] |
8 | fn verify_template_generation() { | 6 | fn verify_template_generation() { |
@@ -14,6 +12,9 @@ fn verify_template_generation() { | |||
14 | #[test] | 12 | #[test] |
15 | fn check_code_formatting() { | 13 | fn check_code_formatting() { |
16 | if let Err(error) = run_rustfmt(Verify) { | 14 | if let Err(error) = run_rustfmt(Verify) { |
17 | panic!("{}. Please format the code by running `cargo format`", error); | 15 | panic!( |
16 | "{}. Please format the code by running `cargo format`", | ||
17 | error | ||
18 | ); | ||
18 | } | 19 | } |
19 | } | 20 | } |