Do not crash on empty test unit groups, closes #14754
This commit is contained in:
@@ -166,18 +166,23 @@ defmodule ExUnit.Runner do
|
||||
running
|
||||
end
|
||||
|
||||
defp spawn_modules(config, [{group, [_ | _] = modules} | groups], async?, running) do
|
||||
if max_failures_reached?(config) do
|
||||
running
|
||||
else
|
||||
{pid, ref} =
|
||||
spawn_monitor(fn ->
|
||||
Enum.each(modules, fn {module, params} ->
|
||||
run_module(config, module, async?, group, params)
|
||||
end)
|
||||
end)
|
||||
defp spawn_modules(config, [{group, modules} | groups], async?, running) do
|
||||
cond do
|
||||
max_failures_reached?(config) ->
|
||||
running
|
||||
|
||||
spawn_modules(config, groups, async?, Map.put(running, ref, pid))
|
||||
modules == [] ->
|
||||
spawn_modules(config, groups, async?, running)
|
||||
|
||||
true ->
|
||||
{pid, ref} =
|
||||
spawn_monitor(fn ->
|
||||
Enum.each(modules, fn {module, params} ->
|
||||
run_module(config, module, async?, group, params)
|
||||
end)
|
||||
end)
|
||||
|
||||
spawn_modules(config, groups, async?, Map.put(running, ref, pid))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -720,6 +720,30 @@ defmodule ExUnitTest do
|
||||
assert_receive {:tmp_dir, tmp_dir2} when tmp_dir1 != tmp_dir2
|
||||
end
|
||||
|
||||
test "empty parameterized tests" do
|
||||
defmodule EmptyParameterizedTests do
|
||||
use ExUnit.Case, async: true, parameterize: []
|
||||
|
||||
test "hello world" do
|
||||
assert false
|
||||
end
|
||||
end
|
||||
|
||||
configure_and_reload_on_exit(trace: true)
|
||||
assert capture_io(fn -> ExUnit.run() end) =~ "0 tests"
|
||||
|
||||
defmodule EmptyGroupedParameterizedTests do
|
||||
use ExUnit.Case, async: true, parameterize: [], group: :example
|
||||
|
||||
test "hello world" do
|
||||
assert false
|
||||
end
|
||||
end
|
||||
|
||||
configure_and_reload_on_exit(trace: true)
|
||||
assert capture_io(fn -> ExUnit.run() end) =~ "0 tests"
|
||||
end
|
||||
|
||||
describe "after_suite/1" do
|
||||
test "executes all callbacks set in reverse order" do
|
||||
Process.register(self(), :after_suite_test_process)
|
||||
|
||||
Reference in New Issue
Block a user