Packages

Native desktop GUI framework for Gleam, powered by Iced

Current section

Files

Jump to
plushie_gleam src plushie@testing@timeout.erl
Raw

src/plushie@testing@timeout.erl

-module(plushie@testing@timeout).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plushie/testing/timeout.gleam").
-export([scale/1]).
-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(" Shared timeout scaling for renderer-backed test infrastructure.\n").
-file("src/plushie/testing/timeout.gleam", 16).
-spec multiplier() -> integer().
multiplier() ->
case plushie_ffi:get_env(<<"PLUSHIE_TEST_TIMEOUT"/utf8>>) of
{ok, Value} ->
case gleam_stdlib:parse_int(Value) of
{ok, N} when N > 0 ->
N;
_ ->
1
end;
{error, _} ->
1
end.
-file("src/plushie/testing/timeout.gleam", 12).
?DOC(
" Scale a test infrastructure timeout by `PLUSHIE_TEST_TIMEOUT`.\n"
"\n"
" The variable is an integer multiplier. Unset, invalid, and\n"
" non-positive values use a multiplier of 1.\n"
).
-spec scale(integer()) -> integer().
scale(Base_ms) ->
Base_ms * multiplier().