File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed
Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ defmodule Mix.Compilers.Test do
3636 Mix . shell . info "No stale tests."
3737 :noop
3838
39+ [ ] when test_patterns == [ ] ->
40+ Mix . shell . info "There are no tests to run"
41+ :noop
42+
3943 [ ] ->
4044 Mix . shell . error "Test patterns did not match any file: " <> Enum . join ( test_patterns , ", " )
4145 :noop
Original file line number Diff line number Diff line change @@ -122,8 +122,8 @@ defmodule Mix.Tasks.Test do
122122 ## Configuration
123123
124124 * `:test_paths` - list of paths containing test files, defaults to
125- `["test"]`. It is expected all test paths to contain a `test_helper.exs`
126- file.
125+ `["test"]` if the `test` directory exists, otherwise it defaults to `[]`.
126+ It is expected all test paths to contain a `test_helper.exs` file.
127127
128128 * `:test_pattern` - a pattern to load test files, defaults to `*_test.exs`.
129129
@@ -225,7 +225,7 @@ defmodule Mix.Tasks.Test do
225225 ex_unit_opts = ex_unit_opts ( opts )
226226 ExUnit . configure ( ex_unit_opts )
227227
228- test_paths = project [ :test_paths ] || [ "test" ]
228+ test_paths = project [ :test_paths ] || default_test_paths ( )
229229 Enum . each ( test_paths , & require_test_helper ( & 1 ) )
230230 ExUnit . configure ( merge_helper_opts ( ex_unit_opts ) )
231231
@@ -365,4 +365,12 @@ defmodule Mix.Tasks.Test do
365365 Mix . raise "Cannot run tests because test helper file #{ inspect file } does not exist"
366366 end
367367 end
368+
369+ defp default_test_paths do
370+ if File . dir? ( "test" ) do
371+ [ "test" ]
372+ else
373+ [ ]
374+ end
375+ end
368376end
Original file line number Diff line number Diff line change @@ -108,6 +108,14 @@ defmodule Mix.Tasks.TestTest do
108108 end
109109 end
110110
111+ test "logs test absence for a project with no test paths" do
112+ in_fixture "test_stale" , fn ->
113+ File . rm_rf! "test"
114+
115+ assert_run_output "There are no tests to run"
116+ end
117+ end
118+
111119 test "--listen-on-stdin: runs tests after input" do
112120 in_fixture "test_stale" , fn ->
113121 port = mix_port ( ~w[ test --stale --listen-on-stdin] )
@@ -190,6 +198,10 @@ defmodule Mix.Tasks.TestTest do
190198 end
191199
192200 defp assert_stale_run_output ( opts \\ [ ] , expected ) do
193- assert mix ( ~w[ test --stale] ++ opts ) =~ expected
201+ assert_run_output ( [ "--stale" | opts ] , expected )
202+ end
203+
204+ defp assert_run_output ( opts \\ [ ] , expected ) do
205+ assert mix ( [ "test" | opts ] ) =~ expected
194206 end
195207end
You can’t perform that action at this time.
0 commit comments