@@ -715,123 +715,6 @@ defmodule ExUnitTest do
715
715
assert_receive { :tmp_dir , tmp_dir2 } when tmp_dir1 != tmp_dir2
716
716
end
717
717
718
- test "async tests run concurrently" do
719
- Process . register ( self ( ) , :async_tests )
720
-
721
- defmodule FirstAsyncTest do
722
- use ExUnit.Case , async: true
723
-
724
- test "first test" do
725
- send ( :async_tests , { :first_test , :started } )
726
- Process . sleep ( 10 )
727
- assert true
728
- send ( :async_tests , { :first_test , :finished } )
729
- end
730
- end
731
-
732
- defmodule SecondAsyncTest do
733
- use ExUnit.Case , async: true
734
-
735
- test "second test" do
736
- send ( :async_tests , { :second_test , :started } )
737
- Process . sleep ( 15 )
738
- assert true
739
- send ( :async_tests , { :second_test , :finished } )
740
- end
741
- end
742
-
743
- configure_and_reload_on_exit ( max_cases: 2 )
744
-
745
- test_task =
746
- Task . async ( fn ->
747
- capture_io ( fn -> ExUnit . run ( ) end )
748
- end )
749
-
750
- # Expected test distribution through time
751
- #
752
- # Time (ms): 0 10 20
753
- # |-----|-----|
754
- # CPU0: ( 1 )
755
- # CPU1: ( 2 )
756
- assert_receive ( { :first_test , :started } , 5 )
757
- assert_receive ( { :second_test , :started } , 5 )
758
-
759
- # make sure we don't leave the task running after the outer test finishes
760
- Task . await ( test_task )
761
- end
762
-
763
- test "async tests run concurrently respecting groups" do
764
- Process . register ( self ( ) , :async_grouped_tests )
765
-
766
- defmodule RedOneTest do
767
- use ExUnit.Case , async: true , group: :red
768
-
769
- test "red one test" do
770
- send ( :async_grouped_tests , { :red_one , :started } )
771
- Process . sleep ( 30 )
772
- assert true
773
- send ( :async_grouped_tests , { :red_one , :finished } )
774
- end
775
- end
776
-
777
- defmodule RedTwoTest do
778
- use ExUnit.Case , async: true , group: :red
779
-
780
- test "red two test" do
781
- send ( :async_grouped_tests , { :red_two , :started } )
782
- Process . sleep ( 10 )
783
- assert true
784
- send ( :async_grouped_tests , { :red_two , :finished } )
785
- end
786
- end
787
-
788
- defmodule BlueOneTest do
789
- use ExUnit.Case , async: true , group: :blue
790
-
791
- test "blue one test" do
792
- send ( :async_grouped_tests , { :blue_one , :started } )
793
- Process . sleep ( 10 )
794
- assert true
795
- send ( :async_grouped_tests , { :blue_one , :finished } )
796
- end
797
- end
798
-
799
- defmodule BlueTwoTest do
800
- use ExUnit.Case , async: true , group: :blue
801
-
802
- test "blue two test" do
803
- send ( :async_grouped_tests , { :blue_two , :started } )
804
- Process . sleep ( 10 )
805
- assert true
806
- send ( :async_grouped_tests , { :blue_two , :finished } )
807
- end
808
- end
809
-
810
- configure_and_reload_on_exit ( max_cases: 4 )
811
-
812
- test_task =
813
- Task . async ( fn ->
814
- capture_io ( fn -> ExUnit . run ( ) end )
815
- end )
816
-
817
- # Expected test distribution through time
818
- #
819
- # Time (ms): 0 10 20 30 40
820
- # |-----|-----|-----|-----|
821
- # CPU0: ( R1 )( R2 )
822
- # CPU1: ( B1 )( B2 )
823
- assert_receive ( { :red_one , :started } , 5 )
824
- assert_receive ( { :blue_one , :started } , 5 )
825
- refute_receive ( { :red_two , :started } , 25 )
826
- assert_received ( { :blue_one , :finished } )
827
- assert_received ( { :blue_two , :started } )
828
- assert_receive ( { :blue_two , :finished } , 15 )
829
- assert_receive ( { :red_two , :started } , 15 )
830
-
831
- # make sure we don't leave the task running after the outer test finishes
832
- Task . await ( test_task )
833
- end
834
-
835
718
describe "after_suite/1" do
836
719
test "executes all callbacks set in reverse order" do
837
720
Process . register ( self ( ) , :after_suite_test_process )
@@ -1223,6 +1106,7 @@ defmodule ExUnitTest do
1223
1106
use ExUnit.Case , async: true , group: :red
1224
1107
1225
1108
test "red one test" do
1109
+ Process . sleep ( 5 )
1226
1110
assert true
1227
1111
end
1228
1112
end
@@ -1231,6 +1115,7 @@ defmodule ExUnitTest do
1231
1115
use ExUnit.Case , async: true , group: :blue
1232
1116
1233
1117
test "blue one test" do
1118
+ Process . sleep ( 5 )
1234
1119
assert true
1235
1120
end
1236
1121
end
@@ -1251,7 +1136,7 @@ defmodule ExUnitTest do
1251
1136
end
1252
1137
end
1253
1138
1254
- configure_and_reload_on_exit ( trace: true )
1139
+ configure_and_reload_on_exit ( trace: true , max_cases: 2 )
1255
1140
1256
1141
output =
1257
1142
capture_io ( fn ->
0 commit comments