Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081%% Timed modules run first. Each remaining module keeps its tests in order;%% test/resources.py bounds the number of modules in each parallel batch.-module(albedo_test_runner).
-export([main/0]).
%% Modules whose tests mutate VM-wide state or wait out a wall-clock window%% (a runtime that must answer%% in a second while its store is suspended, a loopback server that must be%% reached in time). With a hundred modules starting at once those windows are%% starved, so these run first and alone: each passes under machine load by%% itself, and failed only against the rest of the suite.-define(TIMED, [ 'daemon@listener_test', 'harness@runtime_test', 'harness@antigravity_errors_test', 'harness@bedrock_converse_http_test', 'openai_api@transport_test', %% Changes the VM-wide clock scale, which other suites must not observe. albedo_transport_once_test, albedo_transport_dual_stack_test]).
main() -> %% albedo_test.gleam is the executable entrypoint, not a test suite. Modules = [ module(Path) || Path <- filelib:wildcard("**/*_test.{erl,gleam}", "test"), Path =/= "albedo_test.gleam", not lists:prefix("manual/", Path) ], case Modules of [] -> error(no_test_modules); _ -> ok end, lists:foreach(fun require_tests/1, Modules), Timed = [Module || Module <- ?TIMED, lists:member(Module, Modules)], Options = [ verbose, no_tty, {report, {gleeunit_progress, [{colored, true}]}}, {scale_timeouts, 10} ], Result = eunit:test( [{inorder, Timed}, {inparallel, workers(), [{inorder, M} || M <- Modules -- Timed]}], Options ), albedo_test_home:cleanup(), erlang:halt( case Result of ok -> 0; _ -> 1 end ).
workers() -> list_to_integer(string:trim(os:cmd("python3 test/resources.py --get gleam"))).
require_tests(Module) -> {module, Module} = code:ensure_loaded(Module), HasTests = lists:any( fun({Name, Arity}) -> Arity =:= 0 andalso (lists:suffix("_test", atom_to_list(Name)) orelse lists:suffix("_test_", atom_to_list(Name))) end, Module:module_info(exports) ), case HasTests of true -> ok; false -> error({no_tests_in_module, Module}) end.
module(Path) -> Name = case filename:extension(Path) of ".gleam" -> string:replace(filename:rootname(Path), "/", "@", all); ".erl" -> filename:basename(Path, ".erl") end, list_to_atom(lists:flatten(Name)).