teodesian / TestRail-Perl

Perl interface to TestRail's REST API
5 stars 8 forks source link

Newer versions of MCE fail to provide ARRAYREFs sometimes #135

Closed teodesian closed 7 years ago

teodesian commented 7 years ago

single elem arrays appear to be de-arrayed. Easy enough

teodesian commented 7 years ago

this is looking pretty scary actually. Seems it's losing data along the way!

teodesian commented 7 years ago

https://rt.cpan.org/Public/Bug/Display.html?id=121643

teodesian commented 7 years ago

According to Mario, I can do more than mitigate this behavior by simply passing an arrayref to mce_loop. As such, this issue is reopened.

marioroy commented 7 years ago

Hi @teodesian.

Folks have wanted the ability for MCE to process a hash as input data. That feature was added recently. But, that made knowing the type to process problematic for an array containing a single element which happens to be a hash ref. MCE will think to process a hash due to being a single element. To ensure MCE is choosing the right type, the solution is to give mce_loop the array ref ( $runs ) instead of ( @$runs ). This is the recommendation when input data contains nested data.

Regards, Mario

teodesian commented 7 years ago

@marioroy it looks like accepting arrayrefs has been a feature of MCE::Loop::run() for some time now, at least as far as github knows:

https://github.com/marioroy/mce-perl/blob/b8b5ac01611dd437fe3912f95378c7621440b995/lib/MCE/Loop.pm#L239

This shouldn't be a problem for the deploy environments I care about, so hopefully I won't have to worry about specifying a minimum version. That is, supposing that my interpretation of the above code is correct.

marioroy commented 7 years ago

@teodesian your interpretation is correct. MCE::Loop supported arrayrefs since introduction or 1.500.