Skip to content

Commit 4e79118

Browse files
committed
Added unittest for recursive aliases.
1 parent f748f85 commit 4e79118

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/cli.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
277277
#[cfg(test)]
278278
mod tests {
279279
use super::*;
280+
use crate::rustc;
281+
use crate::shell::Verbosity;
280282

281283
#[test]
282284
fn is_verbose_test() {
@@ -289,4 +291,20 @@ mod tests {
289291
assert!(is_verbose("-vvvv"));
290292
assert!(!is_verbose("-version"));
291293
}
294+
295+
#[test]
296+
#[should_panic]
297+
fn test_recursive_alias() {
298+
let mut args = Args::default();
299+
let target_list =
300+
rustc::target_list(&mut Verbosity::Quiet.into()).expect("failed to get target list");
301+
302+
parse_subcommand(
303+
"recursive".to_owned(),
304+
&mut args,
305+
&target_list,
306+
Some("recursive"),
307+
)
308+
.ok();
309+
}
292310
}

src/shell.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,14 @@ impl MessageInfo {
208208
pub fn fatal<T: fmt::Display>(&mut self, message: T, code: i32) -> ! {
209209
self.error(message)
210210
.expect("could not display fatal message");
211-
std::process::exit(code);
211+
212+
// need to catch panics in unittests, otherwise
213+
// want the custom styled error message
214+
if cfg!(test) {
215+
panic!("");
216+
} else {
217+
std::process::exit(code);
218+
}
212219
}
213220

214221
/// prints a red 'error' message.

0 commit comments

Comments
 (0)