Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run PHP with -d parameters #212

Closed
Mechazawa opened this issue Jun 10, 2016 · 6 comments
Closed

Run PHP with -d parameters #212

Mechazawa opened this issue Jun 10, 2016 · 6 comments

Comments

@Mechazawa
Copy link

Mechazawa commented Jun 10, 2016

Right now the PHPUnit executable is called directly by the application. This means that /usr/bin/env php is implicitly used to execute php. It would be great to have a parameter that allows us to set uptional ini parameters. Such as -d zend_extension=xdebug.so. Since XDebug isn't always loaded in on every system by default and is sometimes only used to get coverage information.

A way of implementing this would be to add an optional parameter and prepending /usr/bin/env php -d foo=bar -d baz=tor to the command. Currently running paratests with -d zend_extension=xdebug.so does not carry over to the subprocesses it spawns.

// Something like this should do the job
$this->addOption('set-ini', 'd', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 
                 'Set php ini params before execution (ex: -d zend_extension=xdebug.so)');`

Something like --load-extension xdebug.so would also be good.

@dominics
Copy link

As long as you're using the standard runner, it should be possible (albeit annoying) as a workaround to create a small script that does exec php -dzend_extension=xdebug.so phpunit. You name it phpunit-wrapper (or similar) and get paratest to call it using the --phpunit=path/to/phpunit-wrapper command line option.

Unfortunately, this workaround seems to be broken for the WrapperRunner, which uses a hard-coded phpunit wrapper that can't be changed: https://github.com/brianium/paratest/blob/master@{2016-06-27}/src/ParaTest/Runners/PHPUnit/WrapperRunner.php#L46

BTW, I vote 👎 for --load-extension, because my use case is -dmemory_limit; I'd be good to keep this more generic (the WrapperRunner problem above affects any -d flag, because an actual PHP process is no longer seeing $argv I think...)

@KarimGeiger
Copy link

I'd appreciate this feature as well.

@jmalinens
Copy link

+1

1 similar comment
@ghost
Copy link

ghost commented Aug 2, 2018

+1

@paslandau
Copy link

paslandau commented Jan 25, 2019

#361 just got merged into master. Please check if you can use that as a "generic" workaround:

php '-d' 'zend_extension=xdebug.so' bin/paratest -p 4 --coverage-text test/unit --passthru-php="'-d' 'zend_extension=xdebug.so'"

See docs/code-coverage.md (ping #362) for a more in-depth usage example.

@andreasschroth
Copy link
Member

@paslandau is right, so I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants