File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,8 @@ defmodule Mix.Tasks.Test do
116
116
* `--export-coverage` - the name of the file to export coverage results to.
117
117
Only has an effect when used with `--cover`
118
118
119
- * `--failed` - runs only tests that failed the last time they ran
119
+ * `--failed` - runs only tests that failed the last time they ran.
120
+ If there are no pending --failed tests, `mix test` will run all available tests
120
121
121
122
* `--force` - forces compilation regardless of modification times
122
123
@@ -688,7 +689,13 @@ defmodule Mix.Tasks.Test do
688
689
end
689
690
690
691
{ allowed_files , failed_ids } = ExUnit.Filters . failure_info ( manifest_file )
691
- { Keyword . put ( opts , :only_test_ids , failed_ids ) , allowed_files }
692
+
693
+ if MapSet . size ( failed_ids ) == 0 do
694
+ Mix . shell ( ) . info ( "No pending --failed tests, re-running all available tests..." )
695
+ { opts , nil }
696
+ else
697
+ { Keyword . put ( opts , :only_test_ids , failed_ids ) , allowed_files }
698
+ end
692
699
else
693
700
{ opts , nil }
694
701
end
Original file line number Diff line number Diff line change @@ -215,7 +215,9 @@ defmodule Mix.Tasks.TestTest do
215
215
assert mix ( [ "test" , "--failed" ] ) =~ "2 tests, 0 failures"
216
216
217
217
# Nothing should get run if we try it again since everything is passing.
218
- assert mix ( [ "test" , "--failed" ] ) =~ "There are no tests to run"
218
+ output = mix ( [ "test" , "--failed" ] )
219
+ assert output =~ "No pending --failed tests, re-running all available tests..."
220
+ assert output =~ "4 tests, 0 failures"
219
221
220
222
# `--failed` and `--stale` cannot be combined
221
223
output = mix ( [ "test" , "--failed" , "--stale" ] )
You can’t perform that action at this time.
0 commit comments