diff --git a/test/test_helper.exs b/test/test_helper.exs index 723c32e..8702480 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,25 +1,45 @@ # Start distribution for :peer-based distributed tests. # :peer needs the parent node to be alive for dist-connected peers. -unless Node.alive?() do - sname = :"dux_test_#{:erlang.unique_integer([:positive])}" +distributed_exclusion = + if Node.alive?() do + [] + else + sname = :"dux_test_#{:erlang.unique_integer([:positive])}" - case Node.start(sname, :shortnames) do + case Node.start(sname, :shortnames) do + {:ok, _} -> + [] + + {:error, reason} -> + IO.puts( + "⚠ Distribution not available (#{inspect(reason)}) — excluding :distributed tests" + ) + + :distributed + end + end + +# Start testcontainers for integration tests (requires Docker) +old = Process.flag(:trap_exit, true) + +container_exclusion = + case Testcontainers.start_link() do {:ok, _} -> - :ok + [] {:error, reason} -> - IO.puts("⚠ Distribution not available (#{inspect(reason)}) — excluding :distributed tests") + IO.puts("⚠ Test container not available (#{inspect(reason)}) — excluding :container tests") + :container end -end -# Start testcontainers for integration tests (requires Docker) -case Testcontainers.start_link() do - {:ok, _} -> :ok - {:error, _} -> IO.puts("⚠ Docker not available — excluding :container tests") -end +Process.flag(:trap_exit, old) + +Dux.exec("SET memory_limit = '8GB';") + +case List.flatten([distributed_exclusion, container_exclusion]) do + [] -> + ExUnit.start() -if Node.alive?() do - ExUnit.start() -else - ExUnit.start(exclude: [:distributed]) + exclusions -> + ExUnit.start(exclude: exclusions) end