Commit d6625df6 authored by Ted Burghart's avatar Ted Burghart
Browse files

Fixes another flappy test, this time lager_file_backend:trace_files_test_.

parent 48005453
Showing with 17 additions and 3 deletions
+17 -3
......@@ -971,13 +971,27 @@ trace_files_test_() ->
re:split(BinInfo2, "\n", [{return, list}, {parts, 2}])),
?assert(filelib:is_regular(Debug)),
%% XXX Aughhhh, wish I could force this to flush somehow...
timer:sleep(1000),
{ok, BinInfo3} = file:read_file(Debug),
?assertEqual(2, length(re:split(BinInfo3, "\n", [{return, list}, trim])))
% should take about 1 second, try for 3 ...
?assertEqual(2, count_lines_until(2, add_secs(os:timestamp(), 3), Debug, 0))
end}
end
]}.
count_lines_until(Lines, Timeout, File, Last) ->
case timer:now_diff(Timeout, os:timestamp()) > 0 of
true ->
timer:sleep(333),
{ok, Bin} = file:read_file(File),
case erlang:length(re:split(Bin, "\n", [{return, list}, trim])) of
Count when Count < Lines ->
count_lines_until(Lines, Timeout, File, Count);
Count ->
Count
end;
_ ->
Last
end.
formatting_test_() ->
{foreach,
fun() ->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment