lager icon indicating copy to clipboard operation
lager copied to clipboard

Need a more reliable/race-free way to clear a buffer for lager's unit tests

Open candrews opened this issue 7 years ago • 2 comments

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!

candrews avatar Aug 08 '16 20:08 candrews

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.

jadeallenx avatar Jan 20 '17 21:01 jadeallenx

See also #463

jadeallenx avatar Jul 30 '18 04:07 jadeallenx