From: Nathan Froyd Date: Fri, 6 Jan 2017 17:46:56 +0000 (-0500) Subject: disable color shell tests for terminals that don't support color X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~11^2~48^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1621bd0baf25f77a2f6b7765ee79183f2684bf6e;p=cargo.git disable color shell tests for terminals that don't support color Some terminals (e.g. running a shell inside Emacs's shell-mode) don't support color, and running tests that assume the terminal supports color don't work so well. Instead, if color is expected, check the terminal for whether it supports color or not, and act accordingly. --- diff --git a/tests/shell.rs b/tests/shell.rs index 4b03aa6f6..8dc0786fc 100644 --- a/tests/shell.rs +++ b/tests/shell.rs @@ -62,15 +62,19 @@ fn colored_shell() { shell.say("Hey Alex", color::RED).unwrap(); }); let buf = a.lock().unwrap().clone(); - assert_that(&buf[..], - shell_writes(colored_output("Hey Alex\n", - color::RED).unwrap())); + let expected_output = if term.unwrap().supports_color() { + shell_writes(colored_output("Hey Alex\n", color::RED).unwrap()) + } else { + shell_writes("Hey Alex\n") + }; + assert_that(&buf[..], expected_output); } #[test] fn color_explicitly_enabled() { let term = TerminfoTerminal::new(Vec::new()); if term.is_none() { return } + if !term.unwrap().supports_color() { return } let config = ShellConfig { color_config: Always, tty: false }; let a = Arc::new(Mutex::new(Vec::new()));