Current section
Files
Jump to
Current section
Files
src/startest@internal@runner@backend@erlang.erl
-module(startest@internal@runner@backend@erlang).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([run_tests/1]).
-export_type([atom_/0]).
-type atom_() :: any().
-spec gleam_module_name_to_erlang_module_name(binary()) -> binary().
gleam_module_name_to_erlang_module_name(Module_name) ->
_pipe = Module_name,
gleam@string:replace(_pipe, <<"/"/utf8>>, <<"@"/utf8>>).
-spec run_tests(startest@context:context()) -> nil.
run_tests(Ctx) ->
_assert_subject = startest@locator:locate_test_files(Ctx),
{ok, Test_files} = case _assert_subject of
{ok, _} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"startest/internal/runner/backend/erlang"/utf8>>,
function => <<"run_tests"/utf8>>,
line => 20})
end,
Tests@1 = begin
_pipe = Test_files,
_pipe@5 = gleam@list:map(
_pipe,
fun(Test_file) ->
Erlang_module_name = begin
_pipe@1 = erlang:element(2, Test_file),
_pipe@2 = gleam_module_name_to_erlang_module_name(_pipe@1),
erlang:binary_to_atom(_pipe@2)
end,
Tests = begin
_pipe@3 = startest_ffi:get_exports(Erlang_module_name),
gleam@list:map(
_pipe@3,
fun(Pair) ->
{Name, Body} = begin
_pipe@4 = Pair,
gleam@pair:map_first(
_pipe@4,
fun erlang:atom_to_binary/1
)
end,
{test_function,
erlang:element(2, Test_file),
Name,
Body}
end
)
end,
erlang:setelement(4, Test_file, Tests)
end
),
startest@locator:identify_tests(_pipe@5, Ctx)
end,
_pipe@6 = Tests@1,
startest@internal@runner@core:run_tests(_pipe@6, Ctx).