Skip to content

Commit

Permalink
Mix.Test: support --repeat flag
Browse files Browse the repository at this point in the history
  • Loading branch information
azizk committed Oct 15, 2023
1 parent 8a0961c commit d6ec251
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/mix/lib/mix/tasks/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ defmodule Mix.Tasks.Test do
elixir_version_check: :boolean,
failed: :boolean,
stale: :boolean,
repeat: :boolean,
listen_on_stdin: :boolean,
formatter: :keep,
slowest: :integer,
Expand Down Expand Up @@ -573,6 +574,13 @@ defmodule Mix.Tasks.Test do
warn_test_pattern
)

# ExUnit.FailuresManifest.write(matched_test_files, ".mix_repeat_tests")

# matched_test_files |> IO.inspect(label: "test.ex:578: matched_test_files")
# test_paths |> IO.inspect(label: "test.ex:579: test_paths")
# test_elixirc_options |> IO.inspect(label: "test.ex:579: test_elixirc_options")
# opts |> IO.inspect(label: "test.ex:580: opts")

case CT.require_and_run(matched_test_files, test_paths, test_elixirc_options, opts) do
{:ok, %{excluded: excluded, failures: failures, total: total}} ->
Mix.shell(shell)
Expand Down Expand Up @@ -746,6 +754,10 @@ defmodule Mix.Tasks.Test do
Mix.raise("Combining --failed and --stale is not supported.")
end

if opts[:repeat] do
Mix.raise("Combining --failed and --repeat is not supported.")
end

{allowed_files, failed_ids} = ExUnit.Filters.failure_info(manifest_file)
{Keyword.put(opts, :only_test_ids, failed_ids), allowed_files}
else
Expand Down
4 changes: 4 additions & 0 deletions lib/mix/test/mix/tasks/test_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ defmodule Mix.Tasks.TestTest do
describe "--stale" do
test "runs all tests for first run, then none on second" do
in_fixture("test_stale", fn ->
# mix(["test"])
# |> IO.inspect(label: "test_test.exs:64: mix test")
# |> tap(&IO.write(&1))

assert_stale_run_output("2 tests, 0 failures")

assert_stale_run_output("""
Expand Down

0 comments on commit d6ec251

Please sign in to comment.