Current section
Files
Jump to
Current section
Files
src/startest.erl
-module(startest).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/startest.gleam").
-export([describe/2, it/2, xit/2, run/1, default_config/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/startest.gleam", 14).
?DOC(
" Defines a new test suite with the given name.\n"
"\n"
" A suite is a way of grouping related tests together.\n"
"\n"
" `describe`s may also be nested in other `describe`s to form a hierarchy of tests.\n"
).
-spec describe(binary(), list(startest@test_tree:test_tree())) -> startest@test_tree:test_tree().
describe(Name, Suite) ->
{suite, Name, Suite}.
-file("src/startest.gleam", 19).
?DOC(" Defines a test with the given name.\n").
-spec it(binary(), fun(() -> nil)) -> startest@test_tree:test_tree().
it(Name, Body) ->
_pipe = {test, Name, Body, false},
{test, _pipe}.
-file("src/startest.gleam", 29).
?DOC(
" Skips a test defined using `it`.\n"
"\n"
" This can be used to skip running certain tests, but without deleting the code.\n"
" For instance, you might want to do this if a test is flaky and you want to stop\n"
" running it temporarily until it can be fixed.\n"
).
-spec xit(binary(), fun(() -> nil)) -> startest@test_tree:test_tree().
xit(Name, _) ->
_pipe = {test, Name, fun() -> nil end, true},
{test, _pipe}.
-file("src/startest.gleam", 35).
?DOC(" Runs Startest with the provided list of tests.\n").
-spec run(startest@config:config()) -> nil.
run(Config) ->
startest@cli:run(Config).
-file("src/startest.gleam", 40).
?DOC(" Returns the default Startest config.\n").
-spec default_config() -> startest@config:config().
default_config() ->
Discover_describe_tests_pattern@1 = case gleam@regexp:from_string(
<<"_tests$"/utf8>>
) of
{ok, Discover_describe_tests_pattern} -> Discover_describe_tests_pattern;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"startest"/utf8>>,
function => <<"default_config"/utf8>>,
line => 41,
value => _assert_fail,
start => 1249,
'end' => 1326,
pattern_start => 1260,
pattern_end => 1295})
end,
Discover_standalone_tests_pattern@1 = case gleam@regexp:from_string(
<<"_test$"/utf8>>
) of
{ok, Discover_standalone_tests_pattern} -> Discover_standalone_tests_pattern;
_assert_fail@1 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"startest"/utf8>>,
function => <<"default_config"/utf8>>,
line => 42,
value => _assert_fail@1,
start => 1329,
'end' => 1407,
pattern_start => 1340,
pattern_end => 1377})
end,
{config,
[startest@reporters@default:new()],
Discover_describe_tests_pattern@1,
Discover_standalone_tests_pattern@1,
[],
none}.