lager
lager copied to clipboard
Need a more reliable/race-free way to clear a buffer for lager's unit tests
When running the tests, I'm seeing this error:
lager_test_backend: lager_test_ (logging works from a nested list comprehension)...*failed*
in function lager_test_backend:'-lager_test_/0-fun-49-'/0 (test/lager_test_backend.erl, line 247)
in call from lager_test_backend:'-lager_test_/0-fun-50-'/0 (test/lager_test_backend.erl, line 247)
**error:{assertEqual,[{module,lager_test_backend},
{line,247},
{expression,"count ( )"},
{expected,100},
{value,101}]}
output:<<"">>
Here's my erlang version info:
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
If there's any other information I can provide, please let me know.
I'm using release 3.2.1.
Thanks!
That looks like the test buffer failed to properly clear itself. That's usually a race condition between the buffer being cleared and the 1st message arriving in the gen_event mailbox. The failure comes because it expected 100 messages and actually has 101 due to the race.
This has come up before. The solution is a more reliable/race-free way to clear the buffer before running the rest of the test.
See also #463