Skip to content

Commit

Permalink
Expose failures_manifest_path
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 10, 2024
1 parent d1b3063 commit 1a94623
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/ex_unit/lib/ex_unit.ex
Expand Up @@ -275,7 +275,7 @@ defmodule ExUnit do
* `:exit_status` - specifies an alternate exit status to use when the test
suite fails. Defaults to 2;
* `:failures_manifest_file` - specifies a path to the file used to store failures
* `:failures_manifest_path` - specifies a path to the file used to store failures
between runs;
* `:formatters` - the formatters that will print results,
Expand Down
6 changes: 3 additions & 3 deletions lib/ex_unit/lib/ex_unit/runner_stats.ex
Expand Up @@ -36,7 +36,7 @@ defmodule ExUnit.RunnerStats do
failures: 0,
skipped: 0,
excluded: 0,
failures_manifest_file: opts[:failures_manifest_file],
failures_manifest_path: opts[:failures_manifest_path],
failures_manifest: FailuresManifest.new(),
failure_counter: 0,
pids: []
Expand Down Expand Up @@ -69,13 +69,13 @@ defmodule ExUnit.RunnerStats do
{:noreply, state}
end

def handle_cast({:suite_started, _opts}, %{failures_manifest_file: file} = state)
def handle_cast({:suite_started, _opts}, %{failures_manifest_path: file} = state)
when is_binary(file) do
state = %{state | failures_manifest: FailuresManifest.read(file)}
{:noreply, state}
end

def handle_cast({:suite_finished, _}, %{failures_manifest_file: file} = state)
def handle_cast({:suite_finished, _}, %{failures_manifest_path: file} = state)
when is_binary(file) do
FailuresManifest.write!(state.failures_manifest, file)
{:noreply, state}
Expand Down
6 changes: 3 additions & 3 deletions lib/ex_unit/test/ex_unit/runner_stats_test.exs
Expand Up @@ -5,7 +5,7 @@ defmodule ExUnit.RunnerStatsTest do

alias ExUnit.{FailuresManifest, RunnerStats}

@failures_manifest_file "ex_unit_failures_manifest.elixir"
@failures_manifest_path "ex_unit_failures_manifest.elixir"

describe "stats tracking" do
test "counts total, failures, skipped, and excluded tests" do
Expand Down Expand Up @@ -111,7 +111,7 @@ defmodule ExUnit.RunnerStatsTest do
end
end

defp simulate_suite(opts \\ [failures_manifest_file: @failures_manifest_file], fun) do
defp simulate_suite(opts \\ [failures_manifest_path: @failures_manifest_path], fun) do
{:ok, pid} = GenServer.start_link(RunnerStats, opts)
GenServer.cast(pid, {:suite_started, opts})

Expand Down Expand Up @@ -164,6 +164,6 @@ defmodule ExUnit.RunnerStatsTest do
defp state_for(:excluded), do: {:excluded, "reason"}

defp read_failures_manifest do
FailuresManifest.read(@failures_manifest_file)
FailuresManifest.read(@failures_manifest_path)
end
end
6 changes: 3 additions & 3 deletions lib/mix/lib/mix/tasks/test.ex
Expand Up @@ -691,7 +691,7 @@ defmodule Mix.Tasks.Test do
:colors,
:slowest,
:slowest_modules,
:failures_manifest_file,
:failures_manifest_path,
:only_test_ids,
:test_location_relative_path,
:exit_status,
Expand Down Expand Up @@ -776,11 +776,11 @@ defmodule Mix.Tasks.Test do
opts =
Keyword.put_new(
opts,
:failures_manifest_file,
:failures_manifest_path,
Path.join(Mix.Project.manifest_path(), @manifest_file_name)
)

manifest_file = Keyword.get(opts, :failures_manifest_file)
manifest_file = Keyword.get(opts, :failures_manifest_path)

if opts[:failed] do
if opts[:stale] do
Expand Down
10 changes: 5 additions & 5 deletions lib/mix/test/mix/tasks/test_test.exs
Expand Up @@ -40,18 +40,18 @@ defmodule Mix.Tasks.TestTest do
assert ex_unit_opts([]) == [
autorun: false,
exit_status: 2,
failures_manifest_file:
failures_manifest_path:
Path.join(Mix.Project.manifest_path(), ".mix_test_failures")
]
end

test "respect failures_manifest_file option" do
test "respect failures_manifest_path option" do
custom_manifest_file = Path.join(Mix.Project.manifest_path(), ".mix_test_failures_custom")

assert ex_unit_opts(failures_manifest_file: custom_manifest_file) == [
assert ex_unit_opts(failures_manifest_path: custom_manifest_file) == [
autorun: false,
exit_status: 2,
failures_manifest_file: custom_manifest_file
failures_manifest_path: custom_manifest_file
]
end

Expand All @@ -63,7 +63,7 @@ defmodule Mix.Tasks.TestTest do
defp ex_unit_opts_from_given(passed) do
passed
|> ex_unit_opts()
|> Keyword.drop([:failures_manifest_file, :autorun, :exit_status])
|> Keyword.drop([:failures_manifest_path, :autorun, :exit_status])
end
end

Expand Down

0 comments on commit 1a94623

Please sign in to comment.