ciscoheat / buddy

Your friendly BDD testing library for Haxe!
MIT License
96 stars 24 forks source link

StackOverflow Exception due to large callstack in C# #54

Closed joel-arthur closed 8 years ago

joel-arthur commented 8 years ago

I am running buddy using 10+ test "Suites". Each suite has over 20+ "Describes" containing 10+ "Its".

After the 30-35th testcase runs (30-35th dot is output) I get a StackOverflow Exception when targeting C#.

I added a printout for the callstack using CallStack.callStack().length in SuitesRunner.hx -> forEachSeries-> inside the next() function. It reaches well over 3,500 when the crash occurs. It looks like there are too many nested method calls in SuitesRunner.hx when you are running a lot of testcases in one batch.

Also, version 2.0.1 seemed stable for Java and Python, but 2.0.2 is causing failures for me in both languages.

Please let me know if you need any additional information.

joel-arthur commented 8 years ago

Correction, its is after the 99th testcase that I get the exception

ciscoheat commented 8 years ago

Thank you, great info! I'll make a huge test case and see what happens.

ciscoheat commented 8 years ago

I've made some optimizations now that should decrease stack depth quite a bit. Can you try now with version 2.0.3 and see how it goes?

joel-arthur commented 8 years ago

Crashing after the 118th testcase runs now. The call stack continues to grow with every execution.

I am also getting these warnings: C:\HaxeToolkit\haxe\lib\asynctools/0,1,0/AsyncTools.hx:63: characters 12-42 : Warning : Type Float is being cast to the unrelated type aEachLimit.Err C:\HaxeToolkit\haxe\lib\asynctools/0,1,0/AsyncTools.hx:64: characters 5-35 : Warning : Type Float is being cast to the unrelated type aEachLimit.Err C:\HaxeToolkit\haxe\lib\asynctools/0,1,0/AsyncTools.hx:96: lines 96-103 : Warning : Type Float is being cast to the unrelated type aFilterLimit.Err C:\HaxeToolkit\haxe\lib\asynctools/0,1,0/AsyncTools.hx:170: lines 170-194 : Warning : Type Float is being cast to the unrelated type aForEachOfMapLimit.T2 C:\HaxeToolkit\haxe\lib\asynctools/0,1,0/AsyncTools.hx:170: lines 170-194 : Warning : Type Float is being cast to the unrelated type aForEachOfMapLimit.Err

ciscoheat commented 8 years ago

Yes, I'm realizing that it doesn't work to treat everything as async. The solution right now is to flatten the tests and/or spreading them across several BuddySuites.

joel-arthur commented 8 years ago

My tests are in several BuddySuites. If I run the suite that it is on when I get the stack overflow by itself, then I do not get the error.

All of the switches like this:

switch func { case Async(f): f(function() done(null)); case Sync(f): f(); done(null); }

follow the Sync path.

I also noticed if I set the timeoutMs to a lower number allowing some tests to timeout, the run is successful, but only if some of the testcases timeout.

ciscoheat commented 8 years ago

The problem is that Sync calls go deeper and deeper, because all loops are treated as asynchronous. I need to make some serious rewriting to fix that, which I unfortunately don't have time with right now... Another temp fix would be to make some tests async, which would let them exit the huge stack.

ciscoheat commented 8 years ago

Hey, just kidding about the "don't have time". ;) The code is now pretty much split between async and sync, so I really hope 2.0.4 fixes it. Can you take a look? Thanks for testing, this was a great learning experience as well.

About the warnings, I think that's been reported and fixed. Hopefully they will be gone in Haxe 3.3: https://github.com/HaxeFoundation/haxe/issues/5199

joel-arthur commented 8 years ago

Issue is fixed with the latest update. Thank you for fixing this so quickly!