瀏覽代碼

Merge pull request #202 from basho/adt-buildbot-fixes

Make tests pass on buildbot more of the time
pull/205/head
Andrew Thompson 11 年之前
父節點
當前提交
0e2ed22292
共有 6 個檔案被更改,包括 19 行新增4 行删除
  1. +2
    -0
      src/lager_console_backend.erl
  2. +1
    -0
      src/lager_crash_log.erl
  3. +3
    -1
      src/lager_file_backend.erl
  4. +2
    -0
      src/lager_handler_watcher.erl
  5. +1
    -0
      src/lager_util.erl
  6. +10
    -3
      test/lager_test_backend.erl

+ 2
- 0
src/lager_console_backend.erl 查看文件

@ -175,6 +175,7 @@ console_log_test_() ->
unregister(user), unregister(user),
register(user, User), register(user, User),
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[ [
@ -388,6 +389,7 @@ set_loglevel_test_() ->
end, end,
fun(_) -> fun(_) ->
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[ [

+ 1
- 0
src/lager_crash_log.erl 查看文件

@ -253,6 +253,7 @@ filesystem_test_() ->
end, end,
file:delete("crash_test.log"), file:delete("crash_test.log"),
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[ [

+ 3
- 1
src/lager_file_backend.erl 查看文件

@ -476,6 +476,7 @@ filesystem_test_() ->
file:delete("test.log.0"), file:delete("test.log.0"),
file:delete("test.log.1"), file:delete("test.log.1"),
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[ [
@ -607,7 +608,7 @@ filesystem_test_() ->
?assertEqual({ok, <<>>}, file:read_file("test.log")), ?assertEqual({ok, <<>>}, file:read_file("test.log")),
lager:log(info, self(), "Test message1"), lager:log(info, self(), "Test message1"),
?assertEqual({ok, <<>>}, file:read_file("test.log")), ?assertEqual({ok, <<>>}, file:read_file("test.log")),
timer:sleep(1000),
timer:sleep(2000),
{ok, Bin} = file:read_file("test.log"), {ok, Bin} = file:read_file("test.log"),
?assert(<<>> /= Bin) ?assert(<<>> /= Bin)
end end
@ -722,6 +723,7 @@ formatting_test_() ->
file:delete("test.log"), file:delete("test.log"),
file:delete("test2.log"), file:delete("test2.log"),
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[{"Should have two log files, the second prefixed with 2>", [{"Should have two log files, the second prefixed with 2>",

+ 2
- 0
src/lager_handler_watcher.erl 查看文件

@ -134,6 +134,7 @@ reinstall_on_initial_failure_test_() ->
?assert(lists:member(lager_crash_backend, gen_event:which_handlers(lager_event))) ?assert(lists:member(lager_crash_backend, gen_event:which_handlers(lager_event)))
after after
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end end
end end
@ -162,6 +163,7 @@ reinstall_on_runtime_failure_test_() ->
?assertEqual(false, lists:member(lager_crash_backend, gen_event:which_handlers(lager_event))) ?assertEqual(false, lists:member(lager_crash_backend, gen_event:which_handlers(lager_event)))
after after
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end end
end end

+ 1
- 0
src/lager_util.erl 查看文件

@ -629,6 +629,7 @@ check_trace_test() ->
{[{module, '*'}], config_to_mask('!=notice'), anythingbutnotice} {[{module, '*'}], config_to_mask('!=notice'), anythingbutnotice}
], [])), ], [])),
application:stop(lager), application:stop(lager),
application:stop(goldrush),
ok. ok.
is_loggable_test_() -> is_loggable_test_() ->

+ 10
- 3
test/lager_test_backend.erl 查看文件

@ -511,7 +511,7 @@ lager_test_() ->
{"record printing fails gracefully when module is invalid", {"record printing fails gracefully when module is invalid",
fun() -> fun() ->
spawn(fun() -> lager:info("State ~p", [lager:pr({state, 1}, not_a_module)]) end), spawn(fun() -> lager:info("State ~p", [lager:pr({state, 1}, not_a_module)]) end),
timer:sleep(100),
timer:sleep(1000),
{Level, _Time, Message, _Metadata} = pop(), {Level, _Time, Message, _Metadata} = pop(),
?assertMatch(Level, lager_util:level_to_num(info)), ?assertMatch(Level, lager_util:level_to_num(info)),
?assertEqual("State {state,1}", lists:flatten(Message)), ?assertEqual("State {state,1}", lists:flatten(Message)),
@ -566,6 +566,7 @@ setup() ->
cleanup(_) -> cleanup(_) ->
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true). error_logger:tty(true).
@ -620,6 +621,7 @@ error_logger_redirect_crash_test_() ->
fun(_) -> fun(_) ->
application:stop(lager), application:stop(lager),
application:stop(goldrush),
case whereis(crash) of case whereis(crash) of
undefined -> ok; undefined -> ok;
Pid -> exit(Pid, kill) Pid -> exit(Pid, kill)
@ -669,6 +671,7 @@ error_logger_redirect_test_() ->
fun(_) -> fun(_) ->
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[ [
@ -1158,13 +1161,15 @@ async_threshold_test_() ->
error_logger:tty(false), error_logger:tty(false),
application:load(lager), application:load(lager),
application:set_env(lager, error_logger_redirect, false), application:set_env(lager, error_logger_redirect, false),
application:set_env(lager, async_threshold, 10),
application:set_env(lager, async_threshold, 2),
application:set_env(lager, async_threshold_window, 1),
application:set_env(lager, handlers, [{?MODULE, info}]), application:set_env(lager, handlers, [{?MODULE, info}]),
lager:start() lager:start()
end, end,
fun(_) -> fun(_) ->
application:unset_env(lager, async_threshold), application:unset_env(lager, async_threshold),
application:stop(lager), application:stop(lager),
application:stop(goldrush),
error_logger:tty(true) error_logger:tty(true)
end, end,
[ [
@ -1186,7 +1191,9 @@ async_threshold_test_() ->
%% serialize ont the mailbox again %% serialize ont the mailbox again
_ = gen_event:which_handlers(lager_event), _ = gen_event:which_handlers(lager_event),
%% just in case... %% just in case...
timer:sleep(100),
timer:sleep(1000),
lager:info("hello world"),
_ = gen_event:which_handlers(lager_event),
%% async is true again now that the mailbox has drained %% async is true again now that the mailbox has drained
?assertEqual(true, lager_config:get(async)), ?assertEqual(true, lager_config:get(async)),

Loading…
取消
儲存