tony-o / perl6-event-emitter

2 stars 3 forks source link

Flopping Tests #10

Open zoffixznet opened 7 years ago

zoffixznet commented 7 years ago

If you repeatedly run the test suite, once in a while a test dies with send-on-closed channel error:

zoffix@VirtualBox/tmp/tmp.ZV7cVjBo7K/perl6-event-emitter (master)$ prove6
./t/01-use.t ............ 
1..1
ok 1 - Didn't die on use
ok
./t/02-supplytype.t ..... 
1..5
ok 1 - Event::Emitter isa Event::Emitter::Supply
ok 2 - [Regex] Ensure we got the right data from the supply
ok 3 - [Callable] Ensure we got data from Regex
ok 4 - [Str] Ensure we got the right data from the supply
ok 5 - [Callable] Ensure we got data from Str
ok
./t/03-channeltype.t .... 
1..5
ok 1 - Event::Emitter(:threaded) uses Event::Emitter::Channel
ok 2 - [Regex] Ensure we got the right data from the supply
ok 3 - [Callable] Ensure we got data from Regex
ok 4 - [Str] Ensure we got the right data from the supply
ok 5 - [Callable] Ensure we got data from Str
ok
./t/04-emitter-node.t ... 
1..14
ok 1 - create an object that consumes the role
ok 2 - and it does the role
ok 3 - set handler on 'test' event
ok 4 - event got handled
ok 5 - emit to 'test' works
ok 6 - and test handler was right
ok 7 - and the other one wasn't called
ok 8 - dies with a non-code argument
ok 9 - create an object that consumes the role (threaded)
ok 10 - and it does the role (threaded)
ok 11 - set handler on 'test' event (threaded)
ok 12 - emit to 'test' works (threaded)
ok 13 - event got handled (threaded)
ok 14 - dies with a non-code argument (threaded)
Tried to get the result of a broken Promise
  in block  at /tmp/tmp.ZV7cVjBo7K/perl6-event-emitter/lib/Event/Emitter/Channel.pm6 (Event::Emitter::Channel) line 25

Original exception:
    Cannot receive a message on a closed channel
      in block  at /tmp/tmp.ZV7cVjBo7K/perl6-event-emitter/lib/Event/Emitter/Channel.pm6 (Event::Emitter::Channel) line 13

Dubious, test returned 1 (wstat 256, 0x100)
All 14 subtests passed 
./t/05-emitter-typed.t .. 
1..14
ok 1 - create an object that consumes the role
ok 2 - and it does the role
ok 3 - set handler on 'test' event
ok 4 - event got handled
ok 5 - emit with MyEvent works
ok 6 - and test handler was right
ok 7 - and the other one wasn't called
ok 8 - dies with a non-code argument
ok 9 - dies with a non-type argument
ok 10 - create an object that consumes the role (threaded)
ok 11 - and it does the role (threaded)
ok 12 - set handler on 'test' event
ok 13 - emit with MyEvent works (threaded)
ok 14 - event got handled (threaded)
ok
./t/06-inheritable.t .... 
1..1
ok 1 - check that the 2017-06-17T23:39:03.686749Z is a DateTime object (expected: 2017-06-17T23:39:03.686749Z, got: 2017-06-17T23:39:03.686749Z)
ok

Test Summary Report
-------------------
./t/04-emitter-node.t (Wstat: 256 Tests: 14 Failed: 0)
  Non-zero exit status: 1
Files=6, Tests=40,  2 wallclock secs ( 0.03 usr  0.01 sys +  1.63 cusr  0.15 csys =  1.82 CPU)
Result: FAIL
zoffix@VirtualBox/tmp/tmp.ZV7cVjBo7K/perl6-event-emitter (master)$ 
tony-o commented 7 years ago

@zoffixznet does this still flop after PR #11 ?

AlexDaniel commented 7 years ago

@zoffixznet 🙋

zoffixznet commented 7 years ago

@zoffixznet does this still flop after PR #11 ?

Yes, tho now it's due to Test.pm not being thread-safe. I think with the new atomic ops we can make it fix that (at least the part that make the tests flop).

Gonna do it after sleep.

zoffixznet commented 7 years ago

On closer inspection, making Test.pm thread-safer isn't just editing a couple of lines. Even if the variables are handled safely, the printing of output itself can come out of order, so I'd say Test.pm6 will be thread-unsafe for quite some time.

(in my homegrown Testo module, I'll look into addressing this issue, once I find some time to work on that module)

AlexDaniel commented 7 years ago

This has to be reopened then.

zoffixznet commented 7 years ago

FWIW, an easy way to fix it in this module is to just setup a Channel that receives closures and runs them and feed it with tests to run; then output will always be in order. Untested, but it works in my head :)