Skip to content

Commit 92a3e5f

Browse files
committed
fix flaky test
1 parent c928221 commit 92a3e5f

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

apps/debug_adapter/test/variables_test.exs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,31 @@ defmodule ElixirLS.DebugAdapter.VariablesTest do
200200
end
201201

202202
test "port" do
203-
children = Variables.children(hd(:erlang.ports()), 0, 10)
204-
205-
case :os.type() do
206-
{:win32, _} ->
207-
assert children[:name] == ~c"2/2"
208-
209-
_ ->
210-
assert children[:name] == ~c"forker"
203+
# Create our own port for testing instead of relying on system ports
204+
# which may have non-deterministic ordering
205+
# Use a simple command that exists on all platforms
206+
command =
207+
case :os.type() do
208+
{:win32, _} -> ~c"cmd"
209+
_ -> ~c"cat"
210+
end
211+
212+
port = :erlang.open_port({:spawn, command}, [:binary])
213+
214+
try do
215+
children = Variables.children(port, 0, 10)
216+
217+
# Verify we can extract port info - the specific name may vary by OS
218+
# but it should be a charlist matching our command
219+
assert children[:name] == command
220+
assert is_list(children[:name])
221+
assert Enum.all?(children[:name], &is_integer/1)
222+
223+
# Verify other common port info fields exist
224+
assert is_integer(children[:id])
225+
assert is_pid(children[:connected])
226+
after
227+
Port.close(port)
211228
end
212229
end
213230
end

0 commit comments

Comments
 (0)