Skip to content

Commit 54ffb57

Browse files
author
José Valim
committed
Add a test case for printing samples on IO shell
1 parent 8fc0688 commit 54ffb57

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/mix/test/mix/shell/io_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,19 @@ defmodule Mix.Shell.IOTest do
2828
assert capture_io("n", fn -> refute yes?("Ok?") end)
2929
assert capture_io("", fn -> refute yes?("Ok?") end)
3030
end
31+
32+
test "runs a given command" do
33+
assert capture_io("", fn -> assert cmd("echo hello") == 0 end) == "hello\n"
34+
35+
will_print_sample()
36+
assert capture_io("", fn -> assert cmd("echo hello", print_app: false) == 0 end) ==
37+
"hello\n"
38+
assert capture_io("", fn -> assert cmd("echo hello") == 0 end) ==
39+
"==> sample\nhello\n"
40+
end
41+
42+
defp will_print_sample do
43+
Mix.Project.push nil
44+
Mix.Project.push MixTest.Case.Sample
45+
end
3146
end

0 commit comments

Comments
 (0)