ソースを参照

Fixes another flappy test, this time lager_file_backend:trace_files_test_.

pull/385/head
Ted Burghart 8年前
コミット
d6625df684
1個のファイルの変更17行の追加3行の削除
  1. +17
    -3
      src/lager_file_backend.erl

+ 17
- 3
src/lager_file_backend.erl ファイルの表示

@ -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() ->

読み込み中…
キャンセル
保存