Skip to content

Add mix test.failures to list recorded test failures - #16256

Closed
PJUllrich wants to merge 1 commit into
elixir-lang:mainfrom
PJUllrich:mix-test-failures-upstream
Closed

PJUllrich wants to merge 1 commit into
elixir-lang:mainfrom
PJUllrich:mix-test-failures-upstream

Conversation

@PJUllrich

Copy link
Copy Markdown
Contributor

🤖 Codex GPT-6.2-Sol wrote the code below. I reviewed it and wrote the PR description


Adds a new mix test.failures command that prints out the filepath, test name, and test module for the failed tests that mix test --failed would run. Example:

> mix test.failures
test/only_failing_test_failed.exs - test fails (OnlyFailingTest)
test/passing_and_failing_test_failed.exs - test fails (PassingAndFailingTest)
test/passing_and_failing_test_failed.exs - test passes (PassingAndFailingTest)

Open questions

  1. The command name mix test.failures could also be mix test.failed or mix test --list-failures or something else. I'm open for suggestions and have no strong preferences.
  2. I'm unsure about the formatted output. Ideally, the filepaths would also include the line number of the failed tests, but that would require a slightly larger rewrite of ExUnit.FailuresManifest which currently only tracks the ExUnit.test_id() in a {module, test_name :: atom} => test_file :: Path.t() map and doesn't contain the line number of the test. This could happen now, in a later iteration, or not at all. I'm happy with any of these options.

Rationale

I have wanted such a command for a while (4+ years) because if I have a lot of tests, finding the test paths of the failing tests would require me to either scroll through a lot of test output or run mix test --failed and hope that they fail again because otherwise only a green dot appears and they are gone which makes debugging flakey tests difficult, which having a dedicated "hey, which tests failed again?" command makes this simpler.

Also, now I can tell my LLM "Just run this command and fix the failing tests" instead of having to copy&paste the test output into the terminal.

Small bugfix

The test code also fixes a small bug where umbrella apps would write their failure manifests into the same path and later app tests would use the old manifest of an earlier app. Now, each umbrella app writes the manifests into its own path.

List recorded failures without loading or running tests. Keep each umbrella app’s failure manifest scoped to its own test run.

Assisted-by: Codex:GPT-6
@josevalim

Copy link
Copy Markdown
Member

We already have something like --dry-run. Could we use it instead? The downside is that it still load test files but it also combines with all existing options.

@PJUllrich

Copy link
Copy Markdown
Contributor Author

@josevalim yes! A mix test --failed --dry-run does the same trick and even includes the line numbers. Nevermind and sorry to waste your time!

@PJUllrich PJUllrich closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants