aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Mominul Huque <[email protected]>2019-06-15 19:48:50 +0100
committerMuhammad Mominul Huque <[email protected]>2019-06-15 19:48:50 +0100
commit91510db6d8d89e8907a0cbf33e6068259b3bc88b (patch)
tree8c491ef6e810bd1fc4935ab027a10d6de76f0b51
parent41c56c8a0d01d395e49cd199e6050b02a91cff1d (diff)
Fall down of failures
-rw-r--r--Cargo.lock8
-rw-r--r--crates/ra_tools/Cargo.toml3
-rw-r--r--crates/ra_tools/src/bin/pre-commit.rs7
-rw-r--r--crates/ra_tools/src/lib.rs14
-rw-r--r--crates/ra_tools/src/main.rs11
5 files changed, 19 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 03b5794fa..83f8dd33c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1225,9 +1225,8 @@ name = "ra_tools"
1225version = "0.1.0" 1225version = "0.1.0"
1226dependencies = [ 1226dependencies = [
1227 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", 1227 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
1228 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1229 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 1228 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1230 "teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1229 "teraron 0.0.1 (git+https://github.com/mominul/teraron.git?branch=failure)",
1231 "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", 1230 "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
1232] 1231]
1233 1232
@@ -1683,9 +1682,8 @@ dependencies = [
1683[[package]] 1682[[package]]
1684name = "teraron" 1683name = "teraron"
1685version = "0.0.1" 1684version = "0.0.1"
1686source = "registry+https://github.com/rust-lang/crates.io-index" 1685source = "git+https://github.com/mominul/teraron.git?branch=failure#e421b697309661dfee00b4ca3804bd4de09ce2b7"
1687dependencies = [ 1686dependencies = [
1688 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1689 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1687 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1690 "ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 1688 "ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
1691 "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", 1689 "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2143,7 +2141,7 @@ dependencies = [
2143"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" 2141"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
2144"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" 2142"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef"
2145"checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" 2143"checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3"
2146"checksum teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d89ad4617d1dec55331067fadaa041e813479e1779616f3d3ce9308bf46184e" 2144"checksum teraron 0.0.1 (git+https://github.com/mominul/teraron.git?branch=failure)" = "<none>"
2147"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" 2145"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea"
2148"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" 2146"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625"
2149"checksum text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e08bbcb7a3adbda0eb23431206b653bdad3d8dea311e72d36bf2215e27a42579" 2147"checksum text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e08bbcb7a3adbda0eb23431206b653bdad3d8dea311e72d36bf2215e27a42579"
diff --git a/crates/ra_tools/Cargo.toml b/crates/ra_tools/Cargo.toml
index 35ea3231b..a34c8d482 100644
--- a/crates/ra_tools/Cargo.toml
+++ b/crates/ra_tools/Cargo.toml
@@ -6,8 +6,7 @@ authors = ["rust-analyzer developers"]
6publish = false 6publish = false
7 7
8[dependencies] 8[dependencies]
9teraron = "0.0.1" 9teraron = { git = "https://github.com/mominul/teraron.git", branch = "failure" }
10walkdir = "2.1.3" 10walkdir = "2.1.3"
11itertools = "0.8.0" 11itertools = "0.8.0"
12clap = "2.32.0" 12clap = "2.32.0"
13failure = "0.1.4"
diff --git a/crates/ra_tools/src/bin/pre-commit.rs b/crates/ra_tools/src/bin/pre-commit.rs
index c514e992b..95bb55cae 100644
--- a/crates/ra_tools/src/bin/pre-commit.rs
+++ b/crates/ra_tools/src/bin/pre-commit.rs
@@ -1,7 +1,5 @@
1use std::process::Command; 1use std::process::Command;
2 2
3use failure::bail;
4
5use ra_tools::{Result, run_rustfmt, run, project_root, Overwrite}; 3use ra_tools::{Result, run_rustfmt, run, project_root, Overwrite};
6 4
7fn main() -> Result<()> { 5fn main() -> Result<()> {
@@ -19,7 +17,10 @@ fn update_staged() -> Result<()> {
19 .current_dir(&root) 17 .current_dir(&root)
20 .output()?; 18 .output()?;
21 if !output.status.success() { 19 if !output.status.success() {
22 bail!("`git diff --diff-filter=MAR --name-only --cached` exited with {}", output.status); 20 Err(format!(
21 "`git diff --diff-filter=MAR --name-only --cached` exited with {}",
22 output.status
23 ))?;
23 } 24 }
24 for line in String::from_utf8(output.stdout)?.lines() { 25 for line in String::from_utf8(output.stdout)?.lines() {
25 run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?; 26 run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?;
diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs
index 61f6b08cd..821209567 100644
--- a/crates/ra_tools/src/lib.rs
+++ b/crates/ra_tools/src/lib.rs
@@ -3,15 +3,15 @@ use std::{
3 collections::HashMap, 3 collections::HashMap,
4 path::{Path, PathBuf}, 4 path::{Path, PathBuf},
5 process::{Command, Output, Stdio}, 5 process::{Command, Output, Stdio},
6 io::{Error, ErrorKind} 6 io::{Error as IoError, ErrorKind},
7 error::Error
7}; 8};
8 9
9use failure::bail;
10use itertools::Itertools; 10use itertools::Itertools;
11 11
12pub use teraron::{Mode, Overwrite, Verify}; 12pub use teraron::{Mode, Overwrite, Verify};
13 13
14pub type Result<T> = std::result::Result<T, failure::Error>; 14pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
15 15
16pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron"; 16pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron";
17const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; 17const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar";
@@ -128,7 +128,7 @@ pub fn install_format_hook() -> Result<()> {
128 fs::copy("./target/debug/pre-commit", result_path)?; 128 fs::copy("./target/debug/pre-commit", result_path)?;
129 } 129 }
130 } else { 130 } else {
131 return Err(Error::new(ErrorKind::AlreadyExists, "Git hook already created").into()); 131 Err(IoError::new(ErrorKind::AlreadyExists, "Git hook already created"))?;
132 } 132 }
133 Ok(()) 133 Ok(())
134} 134}
@@ -224,7 +224,7 @@ where
224 f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit())); 224 f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit()));
225 let output = cmd.output()?; 225 let output = cmd.output()?;
226 if !output.status.success() { 226 if !output.status.success() {
227 bail!("`{}` exited with {}", cmdline, output.status); 227 Err(format!("`{}` exited with {}", cmdline, output.status))?;
228 } 228 }
229 Ok(output) 229 Ok(output)
230} 230}
@@ -256,11 +256,11 @@ fn tests_from_dir(dir: &Path) -> Result<Tests> {
256 for (_, test) in collect_tests(&text) { 256 for (_, test) in collect_tests(&text) {
257 if test.ok { 257 if test.ok {
258 if let Some(old_test) = res.ok.insert(test.name.clone(), test) { 258 if let Some(old_test) = res.ok.insert(test.name.clone(), test) {
259 bail!("Duplicate test: {}", old_test.name) 259 Err(format!("Duplicate test: {}", old_test.name))?
260 } 260 }
261 } else { 261 } else {
262 if let Some(old_test) = res.err.insert(test.name.clone(), test) { 262 if let Some(old_test) = res.err.insert(test.name.clone(), test) {
263 bail!("Duplicate test: {}", old_test.name) 263 Err(format!("Duplicate test: {}", old_test.name))?
264 } 264 }
265 } 265 }
266 } 266 }
diff --git a/crates/ra_tools/src/main.rs b/crates/ra_tools/src/main.rs
index 285071ea5..846e0223e 100644
--- a/crates/ra_tools/src/main.rs
+++ b/crates/ra_tools/src/main.rs
@@ -1,6 +1,5 @@
1use clap::{App, SubCommand}; 1use clap::{App, SubCommand};
2use core::str; 2use core::str;
3use failure::bail;
4use ra_tools::{ 3use ra_tools::{
5 generate, gen_tests, install_format_hook, run, run_with_output, run_rustfmt, 4 generate, gen_tests, install_format_hook, run, run_with_output, run_rustfmt,
6 Overwrite, Result, run_fuzzer, run_clippy, 5 Overwrite, Result, run_fuzzer, run_clippy,
@@ -64,10 +63,8 @@ fn verify_installed_extensions() -> Result<()> {
64 run_with_output(r"code --list-extensions", ".")? 63 run_with_output(r"code --list-extensions", ".")?
65 }; 64 };
66 if !str::from_utf8(&exts.stdout)?.contains("ra-lsp") { 65 if !str::from_utf8(&exts.stdout)?.contains("ra-lsp") {
67 bail!( 66 Err("Could not install the Visual Studio Code extension. Please make sure you \
68 "Could not install the Visual Studio Code extension. Please make sure you \ 67 have at least NodeJS 10.x installed and try again.")?;
69 have at least NodeJS 10.x installed and try again."
70 );
71 } 68 }
72 Ok(()) 69 Ok(())
73} 70}
@@ -79,7 +76,7 @@ fn fix_path_for_mac() -> Result<()> {
79 const ROOT_DIR: &str = ""; 76 const ROOT_DIR: &str = "";
80 let home_dir = match env::var("HOME") { 77 let home_dir = match env::var("HOME") {
81 Ok(home) => home, 78 Ok(home) => home,
82 Err(e) => bail!("Failed getting HOME from environment with error: {}.", e), 79 Err(e) => Err(format!("Failed getting HOME from environment with error: {}.", e))?,
83 }; 80 };
84 81
85 [ROOT_DIR, &home_dir] 82 [ROOT_DIR, &home_dir]
@@ -93,7 +90,7 @@ fn fix_path_for_mac() -> Result<()> {
93 if !vscode_path.is_empty() { 90 if !vscode_path.is_empty() {
94 let vars = match env::var_os("PATH") { 91 let vars = match env::var_os("PATH") {
95 Some(path) => path, 92 Some(path) => path,
96 None => bail!("Could not get PATH variable from env."), 93 None => Err("Could not get PATH variable from env.")?,
97 }; 94 };
98 95
99 let mut paths = env::split_paths(&vars).collect::<Vec<_>>(); 96 let mut paths = env::split_paths(&vars).collect::<Vec<_>>();