Skip to content

Commit d0696da

Browse files
committed
Verify duplicate dry-run results in tests
1 parent 8ef697c commit d0696da

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

lib/ex_unit/mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ defmodule ExUnit.MixProject do
3939
timeout: 60000,
4040
trace: false,
4141
after_suite: [],
42-
repeat_until_failure: 0
42+
repeat_until_failure: 0,
43+
dry_run: false
4344
]
4445
]
4546
end

lib/mix/lib/mix/compilers/test.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ defmodule Mix.Compilers.Test do
3939
end
4040

4141
defp require_and_run(matched_test_files, test_paths, opts) do
42-
stale = opts[:stale]
42+
dry_run = Keyword.get(opts, :dry_run, false)
43+
stale = Keyword.get(opts, :stale, false)
4344
max_requires = opts[:max_requires]
4445

4546
{test_files, stale_manifest_pid, parallel_require_callbacks} =
46-
if stale do
47+
if stale and not dry_run do
4748
set_up_stale(matched_test_files, test_paths, opts)
4849
else
4950
{matched_test_files, nil, []}

lib/mix/test/mix/tasks/test_test.exs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,34 +741,37 @@ defmodule Mix.Tasks.TestTest do
741741
""")
742742

743743
output = mix(["test", "--dry-run", "--stale"])
744-
745744
assert output =~ "Tests that would be executed:"
746745
assert output =~ "test/a_test_stale.exs:4"
747746
assert output =~ "test/b_test_stale.exs:4"
748747
assert output =~ "test/dry_run_one_test_stale.exs:4"
749748
refute output =~ "test/dry_run_two_test_stale.exs:5"
750749
assert output =~ "1 test, 0 failures, 1 skipped"
751750

752-
# Tests are still marked as stale
751+
# Tests should still be marked as stale
753752
output = mix(["test", "--dry-run", "--stale"])
754753
assert output =~ "1 test, 0 failures, 1 skipped"
755754
end)
756755
end
757756

758757
test "works with --failed" do
759758
in_fixture("test_failed", fn ->
760-
_initial_run = mix(["test"])
761-
output = mix(["test", "--dry-run", "--failed"])
759+
output = mix(["test"])
760+
assert output =~ "4 tests, 2 failures"
762761

762+
output = mix(["test", "--dry-run", "--failed"])
763763
assert output =~ "Tests that would be executed:"
764764
assert output =~ "test/only_failing_test_failed.exs:4"
765765
assert output =~ "test/passing_and_failing_test_failed.exs:5"
766766
assert output =~ "0 tests, 0 failures"
767767

768-
# Tests are still marked as failed
769-
output = mix(["test", "--dry-run", "failed"])
768+
# Force the tests to pass, verify dry-run doesn't actually run them
769+
System.put_env("PASS_FAILING_TESTS", "true")
770+
output = mix(["test", "--dry-run", "--failed"])
770771
assert output =~ "0 tests, 0 failures"
771772
end)
773+
after
774+
System.delete_env("PASS_FAILING_TESTS")
772775
end
773776
end
774777

0 commit comments

Comments
 (0)