Skip to content

Commit

Permalink
Do not allow timeouts in tests
Browse files Browse the repository at this point in the history
If a `should_fail` test timed out, it was considered
as a success, even though it proably shouldn't as it
usually means there's a bug in the typechecker.
  • Loading branch information
xxdavid committed May 3, 2023
1 parent 2a73a6b commit 6c58983
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ gen_should_fail() ->
fun(File) ->
fun() ->
Errors = gradualizer:type_check_file(File, [return_errors]),
Timeouts = [ E || {_File, {form_check_timeout, _}} = E <- Errors],
?assertEqual(0, length(Timeouts)),
%% Test that error formatting doesn't crash
Opts = [{fmt_location, brief},
{fmt_expr_fun, fun erl_prettypr:format/1}],
Expand All @@ -63,12 +65,21 @@ gen_known_problem_should_pass() ->
?_assertEqual(ExpectedErrors, ReturnedErrors)
end, "test/known_problems/should_pass").

% Test succeeds if Gradualizer crashes or if it does type check.
% Test succeeds if Gradualizer crashes, times out, or if it does type check.
% Doing so makes the test suite notify us whenever a known problem is resolved.
gen_known_problem_should_fail() ->
map_erl_files(
fun(File) ->
?_assertNotEqual(nok, safe_type_check_file(File))
Result = safe_type_check_file(File, [return_errors]),
case Result of
crash ->
ok;
Errors ->
ErrorsExceptTimeouts = lists:filter(
fun ({_File, {form_check_timeout, _}}) -> false; (_) -> true end,
Errors),
?_assertEqual(0, length(ErrorsExceptTimeouts))
end
end, "test/known_problems/should_fail").

%%
Expand Down

0 comments on commit 6c58983

Please sign in to comment.