|
1 | | -use cargo::ops::{self, CompileFilter, FilterRule, LibRule}; |
2 | | - |
3 | 1 | use crate::command_prelude::*; |
| 2 | +use cargo::ops::{self, CompileFilter, FilterRule, LibRule}; |
| 3 | +use cargo::util::errors; |
| 4 | +use failure::Fail; |
4 | 5 |
|
5 | 6 | pub fn cli() -> App { |
6 | 7 | subcommand("test") |
@@ -164,12 +165,15 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { |
164 | 165 | let err = ops::run_tests(&ws, &ops, &test_args)?; |
165 | 166 | match err { |
166 | 167 | None => Ok(()), |
167 | | - Some(err) => Err(match err.exit.as_ref().and_then(|e| e.code()) { |
168 | | - Some(i) => CliError::new( |
169 | | - failure::format_err!("{}", err.hint(&ws, &ops.compile_opts)), |
170 | | - i, |
171 | | - ), |
172 | | - None => CliError::new(err.into(), 101), |
173 | | - }), |
| 168 | + Some(err) => { |
| 169 | + let context = failure::format_err!("{}", err.hint(&ws, &ops.compile_opts)); |
| 170 | + let e = match err.exit.as_ref().and_then(|e| e.code()) { |
| 171 | + // Don't show "process didn't exit successfully" for simple errors. |
| 172 | + Some(i) if errors::is_simple_exit_code(i) => CliError::new(context, i), |
| 173 | + Some(i) => CliError::new(err.context(context).into(), i), |
| 174 | + None => CliError::new(err.context(context).into(), 101), |
| 175 | + }; |
| 176 | + Err(e) |
| 177 | + } |
174 | 178 | } |
175 | 179 | } |
0 commit comments