i programming tests phpunit , recently, have come across flag option: --process-isolation after reading runs each test in separate php process, thought might helpful use flag when execute testsuites. however, raises exceptions such as:
phpunit_framework_exception: stty: standard input: invalid argument
or sometimes:
phpunit_framework_exception: notice: constant pear_error_return defined in /usr/share/php/pear.php on line 25 notice: constant pear_error_print defined in /usr/share/php/pear.php on line 26 notice: constant pear_error_trigger defined in /usr/share/php/pear.php on line 27 notice: constant pear_error_die defined in /usr/share/php/pear.php on line 28 notice: constant pear_error_callback defined in /usr/share/php/pear.php on line 29 notice: constant pear_error_exception defined in /usr/share/php/pear.php on line 34 notice: constant pear_ze2 defined in /usr/share/php/pear.php on line 37 notice: constant os_windows defined in /usr/share/php/pear.php on line 44 notice: constant os_unix defined in /usr/share/php/pear.php on line 45 notice: constant pear_os defined in /usr/share/php/pear.php on line 46
the first exception comes when activate flag of process isolation, whereas don't have it, test runs smoothly , without problems. second exception, @ first hand, thought might due conflict in inclusions, after looking on , changing include include_once, exception still keeps coming up.
any appreciated.
i have dug deep issue. explain what's going based on assumption phpunit 3.7 in use.
when use process isolation phpunit still injects global state child process. @ point may hear opponents saying having preserveglobalstate on default contradicting intention of runinseparateprocess. though same way until have realized phpunit.xml has section defines global variables/constants/includepath - without preserveglobalstate these settings never make child process. convinced injection of global state child process needed in cases: need - ensure global state clean enough tests run.
rightfully sebastian bergmann has made code exports globals/constants/required files , puts smarty template in turn becomes php script chlid process. has made 1 small mistake (in view): loaded constants before required files, not after. , makes big difference! here example:
requiredfile.php:
<?php define("some_constant", true); class requiredclass { } ?>
when file loaded parent phpunit process defines constant , adds requiredfile.php list of included files.
then phpunit makes php script child looks like:
<?php define("some_constant", true); require_once "requiredfile.php"; ?>
of course causes php trigger error (constant defined) converted phpunit exception because has no idea error triggered not test code code phpunit has generated.
however constant definitions in code have if (defined()) , if put definition of constants after required files no constant redefinition happens , hence no errors.
with failed phpt tests main culprit pear.php , cannot avoid phpunit uses runtest pear. unless fix smarty template in phpunit 3.7 not able run phpt tests along tests use process isolation.
so need do? easy! head phpunit/framework/process/testcasemethod.tpl.dist , swap {constants} , {included_files} . may not best solution - if cannot change phpunit files. consider bug in phpunit , therefore such fix warranted.
Comments
Post a Comment