diff --git a/lib/ex_unit/lib/ex_unit.ex b/lib/ex_unit/lib/ex_unit.ex index b10c1c8a49..edaa4a0d48 100644 --- a/lib/ex_unit/lib/ex_unit.ex +++ b/lib/ex_unit/lib/ex_unit.ex @@ -70,7 +70,11 @@ defmodule ExUnit do """ @type state :: - nil | {:excluded, binary} | {:failed, failed} | {:invalid, module} | {:skipped, binary} + nil + | {:excluded, binary} + | {:failed, failed} + | {:invalid, ExUnit.TestModule.t()} + | {:skipped, binary} @typedoc "The error state returned by `ExUnit.Test` and `ExUnit.TestModule`" @type failed :: [{Exception.kind(), reason :: term, Exception.stacktrace()}] diff --git a/lib/ex_unit/lib/ex_unit/cli_formatter.ex b/lib/ex_unit/lib/ex_unit/cli_formatter.ex index 472a3bbea9..9e2c4d0d4a 100644 --- a/lib/ex_unit/lib/ex_unit/cli_formatter.ex +++ b/lib/ex_unit/lib/ex_unit/cli_formatter.ex @@ -65,7 +65,8 @@ defmodule ExUnit.CLIFormatter do {:noreply, update_test_timings(config, test)} end - def handle_cast({:test_finished, %ExUnit.Test{state: {:excluded, _}} = test}, config) do + def handle_cast({:test_finished, %ExUnit.Test{state: {:excluded, reason}} = test}, config) + when is_binary(reason) do if config.trace, do: IO.puts(trace_test_excluded(test)) test_counter = update_test_counter(config.test_counter, test) @@ -74,7 +75,8 @@ defmodule ExUnit.CLIFormatter do {:noreply, config} end - def handle_cast({:test_finished, %ExUnit.Test{state: {:skipped, _}} = test}, config) do + def handle_cast({:test_finished, %ExUnit.Test{state: {:skipped, reason}} = test}, config) + when is_binary(reason) do if config.trace do IO.puts(skipped(trace_test_skipped(test), config)) else @@ -87,7 +89,11 @@ defmodule ExUnit.CLIFormatter do {:noreply, config} end - def handle_cast({:test_finished, %ExUnit.Test{state: {:invalid, _}} = test}, config) do + def handle_cast( + {:test_finished, + %ExUnit.Test{state: {:invalid, %ExUnit.TestModule{state: {:failed, _}}}} = test}, + config + ) do if config.trace do IO.puts(invalid(trace_test_result(test), config)) else diff --git a/lib/ex_unit/lib/ex_unit/runner.ex b/lib/ex_unit/lib/ex_unit/runner.ex index 526a834084..34bef5e43f 100644 --- a/lib/ex_unit/lib/ex_unit/runner.ex +++ b/lib/ex_unit/lib/ex_unit/runner.ex @@ -293,8 +293,8 @@ defmodule ExUnit.Runner do {test_module, invalid_tests, []} {:DOWN, ^module_ref, :process, ^module_pid, error} -> - invalid_tests = mark_tests_invalid(tests, test_module) test_module = %{test_module | state: failed({:EXIT, module_pid}, error, [])} + invalid_tests = mark_tests_invalid(tests, test_module) {test_module, invalid_tests, []} end diff --git a/lib/ex_unit/test/ex_unit/failures_manifest_test.exs b/lib/ex_unit/test/ex_unit/failures_manifest_test.exs index 98a5562157..9850a21f47 100644 --- a/lib/ex_unit/test/ex_unit/failures_manifest_test.exs +++ b/lib/ex_unit/test/ex_unit/failures_manifest_test.exs @@ -9,7 +9,7 @@ defmodule ExUnit.FailuresManifestTest do @skipped {:skipped, "reason"} @excluded {:excluded, "reason"} @failed {:failed, []} - @invalid {:invalid, SomeMod} + @invalid {:invalid, %ExUnit.TestModule{}} describe "files_with_failures/1" do test "returns the set of files with failures" do diff --git a/lib/ex_unit/test/ex_unit/runner_stats_test.exs b/lib/ex_unit/test/ex_unit/runner_stats_test.exs index c618c87784..bed956e942 100644 --- a/lib/ex_unit/test/ex_unit/runner_stats_test.exs +++ b/lib/ex_unit/test/ex_unit/runner_stats_test.exs @@ -159,7 +159,7 @@ defmodule ExUnit.RunnerStatsTest do defp state_for(:passed), do: nil defp state_for(:failed), do: {:failed, []} - defp state_for(:invalid), do: {:invalid, TestModule} + defp state_for(:invalid), do: {:invalid, %ExUnit.TestModule{}} defp state_for(:skipped), do: {:skipped, "reason"} defp state_for(:excluded), do: {:excluded, "reason"}