[Bug] PHPUnit "No code coverage driver is available"
sebastian87 opened this issue · comments
Expected behavior
When creating a build for a project with the "coverage: true"-flag, a coverage report should be created and be available at the given url in the build log.
Actual behavior
-
PHPUnit says, its is not being run with xdebug enabled:
- "Error: No code coverage driver is available" (see build log below)
- "If you see a warning while running tests that no code coverage driver is available, it means that you are using the PHP CLI binary (php) and do not have Xdebug loaded." (see: https://phpunit.readthedocs.io/en/9.1/code-coverage-analysis.html)
-
The empty report directory exists in the docker "worker"-container (not in "web"-container).
-
Both urls in the "Building Log" start with "http:/" instead of "http://" ("http" instead of "https" is correct in this case).
-
When open the urls, an error message is shown (because the "index.html" doesn't exist):
Sorry, there was a problem
Message: Controller does not exist!
File: /var/www/html/src/Application.php
Line: 130
Trace:
#0 /var/www/html/src/Application.php(149): PHPCensor\Application->handleRequestInner()
#1 /var/www/html/public/index.php(8): PHPCensor\Application->handleRequest()
#2 {main}
Steps to reproduce
Docker + PHP Censor build config (see below).
Environment
- PHP Censor v1.1.5
- php-censor/docker-php-censor 1.1.5
PHP Censor build config
build_settings:
ignore:
- vendor
- ./tests
allowed_warnings: -1
setup:
composer:
action: install
ignore_platform_reqs: true
test:
php_unit:
config:
- phpunit.xml
directories:
- tests
coverage: true
Building Log
Config before repository clone (DB): {"build_settings":{"ignore":["vendor","./tests"],"allowed_warnings":-1},"setup":{"composer":{"action":"install","ignore_platform_reqs":true}},"test":{"php_unit":{"config":["phpunit.xml"],"directories":["tests"],"coverage":true}}}
Args: ["export GIT_SSH=\"/tmp/sh_FePJea\" && cd .. && git clone --recursive -b \"%s\" \"%s\" \"%s\"","master","ssh:/git@(...).git","<BUILD_PATH>/"]
Command: export GIT_SSH="/tmp/sh_FePJea" && cd .. && git clone --recursive -b "master" "ssh:/git@(...).git" "<BUILD_PATH>/"
Cloning into '<PHP_CENSOR_PATH>/runtime/builds/1/33_b7d9a931'...
Execution status: 0
Args: ["cd \"%s\" && git checkout %s --quiet","<BUILD_PATH>/","f85c638140f2c9774578c339246da21fbcafd043"]
Command: cd "<BUILD_PATH>/" && git checkout f85c638140f2c9774578c339246da21fbcafd043 --quiet
Execution status: 0
Args: ["cd \"%s\" && git rev-parse HEAD","<BUILD_PATH>/"]
Command: cd "<BUILD_PATH>/" && git rev-parse HEAD
f85c638140f2c9774578c339246da21fbcafd043
Execution status: 0
Args: ["cd \"%s\" && git log -1 --pretty=format:%%s %s","<BUILD_PATH>/","f85c638140f2c9774578c339246da21fbcafd043"]
Command: cd "<BUILD_PATH>/" && git log -1 --pretty=format:%s f85c638140f2c9774578c339246da21fbcafd043
8420: add debug
Execution status: 0
Args: ["cd \"%s\" && git log -1 --pretty=format:%%ae %s","<BUILD_PATH>/","f85c638140f2c9774578c339246da21fbcafd043"]
Command: cd "<BUILD_PATH>/" && git log -1 --pretty=format:%ae f85c638140f2c9774578c339246da21fbcafd043
(...)
Execution status: 0
Build config from project (DB)
Final config: {"build_settings":{"ignore":["vendor","./tests"],"allowed_warnings":-1},"setup":{"composer":{"action":"install","ignore_platform_reqs":true}},"test":{"php_unit":{"config":["phpunit.xml"],"directories":["tests"],"coverage":true}}}
Working copy created: <BUILD_PATH>/
RUNNING PLUGIN: Composer (Stage: Setup)
Directory: <BUILD_PATH>/
Plugin options: {"action":"install","ignore_platform_reqs":true}
Looking for binary: composer, priority = local
Found in (system): composer
Using --ignore-platform-reqs flag
Args: ["/usr/bin/composer --no-ansi --no-interaction --ignore-platform-reqs --working-dir=\"%s\" %s","<BUILD_PATH>/","install"]
Command: /usr/bin/composer --no-ansi --no-interaction --ignore-platform-reqs --working-dir="<BUILD_PATH>/" install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 31 installs, 0 updates, 0 removals
- Installing (...)/graphql-query-builder (dev-master af31ea6): Cloning af31ea66d4 from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing matthiasmullie/scrapbook (1.4.7): Loading from cache
- Installing psr/log (1.1.3): Loading from cache
- Installing myclabs/deep-copy (1.9.5): Loading from cache
- Installing sebastian/version (2.0.1): Loading from cache
- Installing sebastian/resource-operations (1.0.0): Loading from cache
- Installing sebastian/recursion-context (2.0.0): Loading from cache
- Installing sebastian/object-enumerator (2.0.1): Loading from cache
- Installing sebastian/global-state (1.1.1): Loading from cache
- Installing sebastian/exporter (2.0.0): Loading from cache
- Installing sebastian/environment (2.0.0): Loading from cache
- Installing sebastian/diff (1.4.3): Loading from cache
- Installing sebastian/comparator (1.2.4): Loading from cache
- Installing symfony/polyfill-ctype (v1.17.0): Loading from cache
- Installing symfony/yaml (v4.4.8): Loading from cache
- Installing doctrine/instantiator (1.3.0): Loading from cache
- Installing webmozart/assert (1.8.0): Loading from cache
- Installing phpdocumentor/reflection-common (2.1.0): Loading from cache
- Installing phpdocumentor/type-resolver (1.1.0): Loading from cache
- Installing phpdocumentor/reflection-docblock (5.1.0): Loading from cache
- Installing phpspec/prophecy (v1.10.3): Loading from cache
- Installing phpunit/php-text-template (1.2.1): Loading from cache
- Installing phpunit/phpunit-mock-objects (3.4.4): Loading from cache
- Installing phpunit/php-timer (1.0.9): Loading from cache
- Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
- Installing phpunit/php-token-stream (2.0.2): Loading from cache
- Installing phpunit/php-file-iterator (1.4.5): Loading from cache
- Installing phpunit/php-code-coverage (4.0.8): Loading from cache
- Installing phpunit/phpunit (5.7.27): Loading from cache
matthiasmullie/scrapbook suggests installing ext-apc (>=3.1.1)
matthiasmullie/scrapbook suggests installing ext-couchbase (>=2.0.0)
matthiasmullie/scrapbook suggests installing ext-memcached (>=2.0.0)
matthiasmullie/scrapbook suggests installing ext-redis (>=2.2.0 || 0.0.0.0)
matthiasmullie/scrapbook suggests installing league/flysystem (~1.0)
sebastian/global-state suggests installing ext-uopz (*)
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
2 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Execution status: 0
PLUGIN: SUCCESS
RUNNING PLUGIN: PHP Unit (Stage: Test)
Directory: <BUILD_PATH>/
Plugin options: {"config":["phpunit.xml"],"directories":["tests"],"coverage":true}
Looking for binary: phpunit, priority = local
Found in <BUILD_PATH>/vendor/bin (local): phpunit
Args: ["<BUILD_PATH>/vendor/bin/phpunit %s %s","--coverage-html \"<PHP_CENSOR_PATH>/public/artifacts/phpunit/1/33_b7d9a931\" --coverage-text --log-json \"/tmp/jlog_MkAofo\" ","tests"]
Command: <BUILD_PATH>/vendor/bin/phpunit --coverage-html "<PHP_CENSOR_PATH>/public/artifacts/phpunit/1/33_b7d9a931" --coverage-text --log-json "/tmp/jlog_MkAofo" tests
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.33
Configuration: <BUILD_PATH>/phpunit.xml
Warning: Deprecated JSON test listener used
Error: No code coverage driver is available
.S.SS. 6 / 6 (100%)
Time: 43 ms, Memory: 4.00MB
There were 3 skipped tests:
(...)
OK, but incomplete, skipped, or risky tests!
Tests: 6, Assertions: 3, Skipped: 3.
Execution status: 0
PHPUnit successful build coverage report.
You can use coverage report for this build: http:/(...)/artifacts/phpunit/1/33_b7d9a931/index.html
Or coverage report for last build in the branch: http:/(...)/artifacts/phpunit/1/master_0f54fc40/index.html
PLUGIN: SUCCESS
BUILD SUCCESS!
REMOVING BUILD.
@sebastian87 Thank you for the useful detailed report! 👍 As I see all problems with docker images and compose files.
I created issues php-censor/docker-php-censor#45 and php-censor/docker-php-censor#46 for this.
@corpsee thanks for creating the docker-issues; I was not sure if the issue was docker related or not.