Current section
Files
Jump to
Current section
Files
src/startest@internal@runner@core.erl
-module(startest@internal@runner@core).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/startest/internal/runner/core.gleam").
-export([run_tests/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/startest/internal/runner/core.gleam", 123).
?DOC(false).
-spec run_test(startest@test_case:test()) -> startest@test_case:test_outcome().
run_test(Test_case) ->
case erlang:element(4, Test_case) of
true ->
skipped;
false ->
case startest@test_failure:rescue(erlang:element(3, Test_case)) of
{ok, nil} ->
passed;
{error, Err} ->
{failed, Err}
end
end.
-file("src/startest/internal/runner/core.gleam", 21).
?DOC(false).
-spec run_tests(list(startest@locator:test_file()), startest@context:context()) -> nil.
run_tests(Test_files, Ctx) ->
Discovery_duration = begin
_pipe = erlang:element(5, Ctx),
gleam@time@timestamp:difference(
_pipe,
bigben@clock:now(erlang:element(3, Ctx))
)
end,
Tests = begin
_pipe@1 = Test_files,
_pipe@4 = gleam@list:flat_map(
_pipe@1,
fun(Test_file) -> _pipe@2 = erlang:element(4, Test_file),
_pipe@3 = gleam@list:flat_map(
_pipe@2,
fun startest@test_tree:all_tests/1
),
gleam@list:map(
_pipe@3,
fun(Pair) ->
{Full_test_name, Test_case} = Pair,
{erlang:element(2, Test_file),
Full_test_name,
Test_case}
end
) end
),
gleam@list:filter(
_pipe@4,
fun(Tuple) ->
{_, Full_test_name@1, _} = Tuple,
case erlang:element(6, erlang:element(2, Ctx)) of
{some, Test_name_pattern} ->
gleam_stdlib:contains_string(
Full_test_name@1,
Test_name_pattern
);
none ->
true
end
end
)
end,
Test_count = erlang:length(Tests),
startest@logger:log(
erlang:element(4, Ctx),
<<<<"Running "/utf8, (erlang:integer_to_binary(Test_count))/binary>>/binary,
" tests"/utf8>>
),
Execution_started_at = bigben@clock:now(erlang:element(3, Ctx)),
Executed_tests = begin
_pipe@5 = Tests,
gleam@list:map(
_pipe@5,
fun(Tuple@1) ->
{_, Full_test_name@2, Test_case@1} = Tuple@1,
Test_case@2 = {test,
Full_test_name@2,
erlang:element(3, Test_case@1),
erlang:element(4, Test_case@1)},
{executed_test, Test_case@2, run_test(Test_case@2)}
end
)
end,
Execution_duration = begin
_pipe@6 = Execution_started_at,
gleam@time@timestamp:difference(
_pipe@6,
bigben@clock:now(erlang:element(3, Ctx))
)
end,
Reporting_started_at = bigben@clock:now(erlang:element(3, Ctx)),
Reporter_ctx = {reporter_context, erlang:element(4, Ctx)},
_pipe@7 = erlang:element(2, erlang:element(2, Ctx)),
gleam@list:each(
_pipe@7,
fun(Reporter) ->
_pipe@8 = Executed_tests,
gleam@list:each(
_pipe@8,
fun(Executed_test) ->
(erlang:element(2, Reporter))(Reporter_ctx, Executed_test)
end
),
(erlang:element(3, Reporter))(Reporter_ctx)
end
),
Reporting_duration = begin
_pipe@9 = Reporting_started_at,
gleam@time@timestamp:difference(
_pipe@9,
bigben@clock:now(erlang:element(3, Ctx))
)
end,
Skipped_tests = begin
_pipe@10 = Executed_tests,
gleam@list:filter_map(
_pipe@10,
fun(Executed_test@1) -> case erlang:element(3, Executed_test@1) of
skipped ->
{ok, erlang:element(2, Executed_test@1)};
passed ->
{error, nil};
{failed, _} ->
{error, nil}
end end
)
end,
Failed_tests = begin
_pipe@11 = Executed_tests,
gleam@list:filter_map(
_pipe@11,
fun(Executed_test@2) -> case erlang:element(3, Executed_test@2) of
{failed, Failure} ->
{ok, {erlang:element(2, Executed_test@2), Failure}};
passed ->
{error, nil};
skipped ->
{error, nil}
end end
)
end,
startest@reporter:report_summary(
Ctx,
Test_files,
Executed_tests,
Skipped_tests,
Failed_tests,
Discovery_duration,
Execution_duration,
Reporting_duration
),
Exit_code = case gleam@list:is_empty(Failed_tests) of
true ->
0;
false ->
1
end,
erlang:halt(Exit_code).