Skip to content

Commit

Permalink
Parallelize CT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Jun 2, 2024
1 parent 314ca8b commit b7d3c32
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5746,8 +5746,10 @@ type_check_forms(Forms, Opts) ->
%% a Gradualizer (NOT the checked program!) error.
-spec type_check_form_with_timeout(expr(), [any()], boolean(), env(), [any()]) -> [any()].
type_check_form_with_timeout(Function, Errors, StopOnFirstError, Env, Opts) ->
%% TODO: make FormCheckTimeOut configurable
FormCheckTimeOut = ?form_check_timeout_ms,
FormCheckTimeOut = case lists:keyfind(form_check_timeout_ms, 1, Opts) of
false -> ?form_check_timeout_ms;
{form_check_timeout_ms, MS} -> MS
end,
?verbose(Env, "Spawning async task...~n", []),
Self = self(),
Task = fun () ->
Expand Down
11 changes: 7 additions & 4 deletions test/known_problems_should_fail_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ init_per_suite(Config0) ->
{ok, _} = application:ensure_all_started(gradualizer),
ok = load_prerequisites(AppBase),
{ok, TestNames} = gradualizer_dynamic_suite:reload(Config),
case all() of
case all_tests() of
TestNames -> ok;
_ -> ct:fail("Please update all/0 to list all tests")
_ -> ct:fail("Please update all_tests/0 to list all tests")
end,
Config.

Expand All @@ -53,10 +53,13 @@ init_per_testcase(_TestCase, Config) ->
end_per_testcase(_TestCase, _Config) ->
ok.

all() ->
[{group, all_tests}].

groups() ->
[].
[{all_tests, [parallel], all_tests()}].

all() ->
all_tests() ->
[arith_op,binary_comprehension,case_pattern_should_fail,
exhaustive_argumentwise,exhaustive_expr,exhaustive_map_variants,
exhaustive_remote_map_variants,guard_should_fail,infer_any_pattern,
Expand Down
11 changes: 7 additions & 4 deletions test/known_problems_should_pass_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ init_per_suite(Config0) ->
{ok, _} = application:ensure_all_started(gradualizer),
ok = load_prerequisites(AppBase),
{ok, TestNames} = gradualizer_dynamic_suite:reload(Config),
case all() of
case all_tests() of
TestNames -> ok;
_ -> ct:fail("Please update all/0 to list all tests")
_ -> ct:fail("Please update all_tests/0 to list all tests")
end,
Config.

Expand All @@ -51,10 +51,13 @@ init_per_testcase(_TestCase, Config) ->
end_per_testcase(_TestCase, _Config) ->
ok.

all() ->
[{group, all_tests}].

groups() ->
[].
[{all_tests, [parallel], all_tests()}].

all() ->
all_tests() ->
[arith_op_arg_types,binary_exhaustiveness_checking_should_pass,
call_intersection_function_with_union_arg_should_pass,
different_normalization_levels,elixir_list_first,error_in_guard,
Expand Down
11 changes: 7 additions & 4 deletions test/should_fail_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ init_per_suite(Config0) ->
{ok, _} = application:ensure_all_started(gradualizer),
ok = load_prerequisites(AppBase),
{ok, TestNames} = gradualizer_dynamic_suite:reload(Config),
case all() of
case all_tests() of
TestNames -> ok;
_ -> ct:fail("Please update all/0 to list all tests")
_ -> ct:fail("Please update all_tests/0 to list all tests")
end,
Config.

Expand Down Expand Up @@ -56,10 +56,13 @@ init_per_testcase(_TestCase, Config) ->
end_per_testcase(_TestCase, _Config) ->
ok.

all() ->
[{group, all_tests}].

groups() ->
[].
[{all_tests, [parallel], all_tests()}].

all() ->
all_tests() ->
[annotated_types_fail,arg,arith_op_fail,arity_mismatch,
bc_fail,bin_expression,bin_type_error,branch,branch2,call,
call_intersection_function_with_union_arg_fail,case_pattern,
Expand Down
13 changes: 8 additions & 5 deletions test/should_pass_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ init_per_suite(Config0) ->
{ok, _} = application:ensure_all_started(gradualizer),
ok = load_prerequisites(AppBase),
{ok, TestNames} = gradualizer_dynamic_suite:reload(Config),
case all() of
case all_tests() of
TestNames -> ok;
_ -> ct:fail("Please update all/0 to list all tests")
_ -> ct:fail("Please update all_tests/0 to list all tests")
end,
Config.

Expand Down Expand Up @@ -57,10 +57,13 @@ init_per_testcase(_TestCase, Config) ->
end_per_testcase(_TestCase, _Config) ->
ok.

all() ->
[{group, all_tests}].

groups() ->
[].
[{all_tests, [parallel], all_tests()}].

all() ->
all_tests() ->
[alias_in_pattern,andalso_any,ann_types,annotated_types,any,
any_doesnt_have_type_none_pass,any_pattern,bc_pass,
binary_exhaustiveness_checking,binary_in_union,binary_literal_pattern,
Expand Down Expand Up @@ -101,4 +104,4 @@ all() ->
variable_binding_leaks].

should_pass_template(_@File) ->
?assertEqual(ok, gradualizer:type_check_file(_@File)).
?assertEqual(ok, gradualizer:type_check_file(_@File, [{form_check_timeout_ms, 2000}])).

0 comments on commit b7d3c32

Please sign in to comment.