Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -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
Loading