Repair CHECK and INIT
From Perl Archiving Toolkit
CHECK and INIT blocks aren't executed inside an eval "". This is a problem for some CPAN modules.
In order to make these things sort-of-work, it could be possible to do the following: (Much thanks for Rafael Garcia-Suarez for the suggestions. I'm quoting him verbatim here and there.)
- Write XS which can access the PL_checkav array of code refs (for check blocks) and the PL_initav array of code refs for init blocks.
- Also, INIT blocks are freed by default after the main compilation phase. To avoid special blocks to be freed, you need to use B::save_BEGINs().
- Put a UNITCHECK in this eval, that will call an XS subroutine to run the CHECK/INIT blocks somehow.
- Note: UNITCHECK will only be available in 5.10 and up. So for CHECK/INIT to work, users would need to upgrade to 5.10 (when it's out).
Any volunteers to try this out? An alternative approach which might work for modules that use CHECK blocks (but not INIT) would be to convince the authors to use Check::UnitCheck which runs the block in UNITCHECK if available and in CHECK if not. That would degrade rather gracefully in case of old (err, current) perls.
