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

TestCommand > Passing on ini settings to phpunit/paratest #284

Open
JeroenVanOort opened this issue Sep 8, 2023 · 1 comment
Open

TestCommand > Passing on ini settings to phpunit/paratest #284

JeroenVanOort opened this issue Sep 8, 2023 · 1 comment

Comments

@JeroenVanOort
Copy link

We use PCOV to collect code coverage. However, we only enable PCOV when we are running tests(using -d pcov.enabled=1), so that it doesn't slow down any other running of the code. This has worked fine with collision 6 / phpunit 9, but it doesn't work any more for collision 7 / phpunit 10. This seems to have to do with the -d argument not being passed on to the phpunit/paratest command.

This works fine:

php -d pcov.enabled=1 vendor/bin/phpunit --coverage-text

but

php -d pcov.enabled=1 artisan test --coverage

starts it's output with

WARN No code coverage driver available.

Apparently, this check passed and it is PHPUnit itself that is giving the warning.

When I change return array_merge([PHP_BINARY], $command); to return array_merge([PHP_BINARY, '-d pcov.enabled=1'], $command); (https://github.com/nunomaduro/collision/blob/v7.x/src/Adapters/Laravel/Commands/TestCommand.php#L179), coverage works just fine.

The challenge here seems to be to find an elegant way to set options like this. I think this would be the easiest way:

php -d pcov.enabled=1 artisan test --coverage -d pcov.enabled=1

All -d arguments would be passed directly to PHP.

What are your thoughts on this? I'd be willing to make a PR.

@oprypkhantc
Copy link

oprypkhantc commented Nov 22, 2023

Btw, you can workaround this without a fork by using an environment variable:

// docker-php-ext-pcov.ini

pcov.enabled=${PCOV_ENABLED}

and then

PCOV_ENABLED=true php artisan test -p --coverage-text
PCOV_ENABLED=false php artisan test -p --coverage-text
php artisan test -p --coverage-text

all work as expected.

It's not to say that this issue is irrelevant; I still believe it should be fixed so we don't have to do workarounds :)

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

No branches or pull requests

2 participants