Skip to content

Commit 272ec8c

Browse files
author
José Valim
committed
Fix mix shell tests when ansi escapes are disabled
Signed-off-by: José Valim <[email protected]>
1 parent a0e8e1c commit 272ec8c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/mix/test/mix/shell_test.exs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ defmodule Mix.ShellTest do
3333
assert_received {:mix_shell, :yes?, ["hello?"]}
3434

3535
assert Mix.shell.cmd("echo first") == 0
36-
36+
3737
nl = os_newline
3838
assert_received {:mix_shell, :run, ["first" <> ^nl]}
3939
end
@@ -44,8 +44,13 @@ defmodule Mix.ShellTest do
4444
assert capture_io(fn -> Mix.shell.info "abc" end) ==
4545
"abc\n"
4646

47-
assert capture_io(:stderr, fn -> Mix.shell.error "def" end) ==
48-
"#{IO.ANSI.red}#{IO.ANSI.bright}def#{IO.ANSI.reset}\n"
47+
if IO.ANSI.enabled? do
48+
assert capture_io(:stderr, fn -> Mix.shell.error "def" end) ==
49+
"#{IO.ANSI.red}#{IO.ANSI.bright}def#{IO.ANSI.reset}\n"
50+
else
51+
assert capture_io(:stderr, fn -> Mix.shell.error "def" end) ==
52+
"def\n"
53+
end
4954

5055
assert capture_io("world", fn -> assert Mix.shell.prompt("hello?") == "world" end) ==
5156
"hello? "

0 commit comments

Comments
 (0)