-module(startest@internal@runner@core). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([run_tests/2]). -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. -spec run_tests(list(startest@locator:test_file()), startest@context:context()) -> nil. run_tests(Test_files, Ctx) -> Discovery_duration = begin _pipe = bigben@clock:now(erlang:element(3, Ctx)), birl:difference(_pipe, erlang:element(5, 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 = gleam@list:length(Tests), startest@logger:log( erlang:element(4, Ctx), <<<<"Running "/utf8, (gleam@int:to_string(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 = bigben@clock:now(erlang:element(3, Ctx)), birl:difference(_pipe@6, Execution_started_at) 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 = bigben@clock:now(erlang:element(3, Ctx)), birl:difference(_pipe@9, Reporting_started_at) end, Failed_tests = begin _pipe@10 = Executed_tests, gleam@list:filter_map( _pipe@10, fun(Executed_test@1) -> case erlang:element(3, Executed_test@1) of {failed, Failure} -> {ok, {erlang:element(2, Executed_test@1), Failure}}; passed -> {error, nil}; skipped -> {error, nil} end end ) end, startest@reporter:report_summary( Ctx, Test_files, Executed_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).