Skip to content

Commit 1af6a1f

Browse files
authored
Update profile.tprof_test.exs
Fixes the sort issue that happen on `Erlang 28.0` where both columns have equal value. I've used `[^\n]+3\.\d{2}\n` to match `3.00` value of `PER CALL` column at the end of the line.
1 parent 52495ba commit 1af6a1f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/mix/test/mix/tasks/profile.tprof_test.exs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,22 @@ defmodule Mix.Tasks.Profile.TprofTest do
8383

8484
test "sorts based on memory per call", context do
8585
in_tmp(context.test, fn ->
86-
assert capture_io(fn ->
87-
Tprof.run(["--type", "memory", "--sort", "per_call", "-e", @expr])
88-
end) =~ ~r/\n:erlang\.integer_to_binary\/1.*\nEnum\.each\/2/s
86+
result = capture_io(fn ->
87+
Tprof.run(["--type", "memory", "--sort", "per_call", "-e", @expr])
88+
end)
89+
90+
# TODO: Remove when we require Erlang 28 exclusively
91+
otp_release =
92+
:otp_release
93+
|> :erlang.system_info()
94+
|> List.to_integer()
95+
96+
if otp_release < 28 do
97+
assert result =~ ~r/\n:erlang\.integer_to_binary\/1.*\nEnum\.each\/2/s
98+
else
99+
assert result =~ ~r/\n:erlang\.integer_to_binary\/1[^\n]+3\.\d{2}\n/
100+
assert result =~ ~r/\nEnum\.each\/2[^\n]+3\.\d{2}\n/
101+
end
89102
end)
90103
end
91104

0 commit comments

Comments
 (0)