Current section

Files

Jump to
startest src startest@internal@runner@backend@erlang.erl
Raw

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(Filepath) ->
_pipe = Filepath,
_pipe@1 = gleam@string:slice(
_pipe,
gleam@string:length(<<"test/"/utf8>>),
gleam@string:length(Filepath)
),
_pipe@2 = gleam@string:replace(_pipe@1, <<".gleam"/utf8>>, <<""/utf8>>),
gleam@string:replace(_pipe@2, <<"/"/utf8>>, <<"@"/utf8>>).
-spec run_tests(startest@context:context()) -> nil.
run_tests(Ctx) ->
_assert_subject = startest@locator:locate_test_files(),
{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 = begin
_pipe = Test_files,
_pipe@4 = gleam@list:map(
_pipe,
fun(Filepath) ->
Erlang_module_name = begin
_pipe@1 = Filepath,
_pipe@2 = gleam_module_name_to_erlang_module_name(_pipe@1),
erlang:binary_to_atom(_pipe@2)
end,
_pipe@3 = startest_ffi:get_exports(Erlang_module_name),
gleam@list:map(
_pipe@3,
fun(_capture) ->
gleam@pair:map_first(
_capture,
fun erlang:atom_to_binary/1
)
end
)
end
),
_pipe@5 = gleam@list:flatten(_pipe@4),
startest@locator:identify_tests(_pipe@5, Ctx)
end,
_pipe@6 = Tests,
startest@internal@runner@core:run_tests(_pipe@6, Ctx).