Skip to content

Commit 63d0932

Browse files
authored
Add test for mix test --only async/sync filter (#13651)
1 parent ce92b1c commit 63d0932

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

lib/ex_unit/test/ex_unit_test.exs

+41-1
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,50 @@ defmodule ExUnitTest do
11011101
assert third =~ "ThirdTestFIFO"
11021102
end
11031103

1104+
test "can filter async tests" do
1105+
defmodule FirstTestAsyncTrue do
1106+
use ExUnit.Case, async: true
1107+
1108+
test "first test" do
1109+
assert true
1110+
end
1111+
end
1112+
1113+
defmodule SecondTestAsyncTrue do
1114+
use ExUnit.Case, async: true
1115+
1116+
test "second test" do
1117+
assert true
1118+
end
1119+
end
1120+
1121+
defmodule FirstTestAsyncFalse do
1122+
use ExUnit.Case, async: false
1123+
1124+
test "first test" do
1125+
assert true
1126+
end
1127+
end
1128+
1129+
assert {%{failures: 0, skipped: 0, total: 3, excluded: 1}, _} =
1130+
run_with_filter([include: [async: true], exclude: [:test]], [])
1131+
1132+
assert {%{failures: 0, skipped: 0, total: 3, excluded: 2}, _} =
1133+
run_with_filter([include: [async: false], exclude: [:test]], [
1134+
FirstTestAsyncTrue,
1135+
SecondTestAsyncTrue,
1136+
FirstTestAsyncFalse
1137+
])
1138+
end
1139+
11041140
## Helpers
11051141

11061142
defp run_with_filter(filters, cases) do
1107-
Enum.each(cases, &ExUnit.Server.add_module(&1, {false, nil}))
1143+
Enum.each(cases, fn mod ->
1144+
[config] = mod.__info__(:attributes) |> Keyword.fetch!(:ex_unit_module)
1145+
ExUnit.Server.add_module(mod, config)
1146+
end)
1147+
11081148
ExUnit.Server.modules_loaded(false)
11091149

11101150
opts =

0 commit comments

Comments
 (0)