Skip to content

Commit 09915d5

Browse files
authored
Merge pull request #1 from BHSPitMonkey/pcov
pcov
2 parents afe4b8a + 75ee8b6 commit 09915d5

File tree

5 files changed

+81
-2
lines changed

5 files changed

+81
-2
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,39 @@ env:
1717
matrix:
1818
- DRIVER="xdebug" DEPENDENCIES="high"
1919
- DRIVER="phpdbg" DEPENDENCIES="high"
20+
- DRIVER="pcov" DEPENDENCIES="high"
2021
- DRIVER="xdebug" DEPENDENCIES="low"
2122
- DRIVER="phpdbg" DEPENDENCIES="low"
23+
- DRIVER="pcov" DEPENDENCIES="low"
2224
global:
2325
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
2426

2527
before_install:
2628
- composer self-update
2729
- composer clear-cache
30+
- export COMPOSER_ROOT_VERSION=6.1.99
2831

2932
install:
3033
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS; fi
3134
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi
3235

36+
before_script:
37+
- |
38+
if [[ "$DRIVER" = 'pcov' ]]; then
39+
echo > $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/xdebug.ini
40+
git clone https://github.com/krakjoe/pcov
41+
cd pcov
42+
phpize
43+
./configure
44+
make clean install
45+
echo "extension=pcov.so" > $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/pcov.ini
46+
cd $TRAVIS_BUILD_DIR
47+
fi
48+
3349
script:
3450
- if [[ "$DRIVER" = 'phpdbg' ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
3551
- if [[ "$DRIVER" = 'xdebug' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml; fi
52+
- if [[ "$DRIVER" = 'pcov' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml; fi
3653

3754
after_success:
3855
- bash <(curl -s https://codecov.io/bash)

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"phpunit/php-token-stream": "^3.0.1",
3333
"phpunit/php-text-template": "^1.2.1",
3434
"sebastian/code-unit-reverse-lookup": "^1.0.1",
35-
"sebastian/environment": "^4.0",
35+
"sebastian/environment": "^4.1",
3636
"sebastian/version": "^2.0.1",
3737
"theseer/tokenizer": "^1.1"
3838
},
@@ -57,5 +57,6 @@
5757
"branch-alias": {
5858
"dev-master": "6.1-dev"
5959
}
60-
}
60+
},
61+
"minimum-stability": "dev"
6162
}

src/CodeCoverage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Util\Test;
1515
use SebastianBergmann\CodeCoverage\Driver\Driver;
1616
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
17+
use SebastianBergmann\CodeCoverage\Driver\PCOV;
1718
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
1819
use SebastianBergmann\CodeCoverage\Node\Builder;
1920
use SebastianBergmann\CodeCoverage\Node\Directory;
@@ -905,6 +906,10 @@ private function selectDriver(Filter $filter): Driver
905906
return new Xdebug($filter);
906907
}
907908

909+
if ($runtime->hasPCOV()) {
910+
return new PCOV($filter);
911+
}
912+
908913
throw new RuntimeException('No code coverage driver available');
909914
}
910915

src/Driver/PCOV.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* This file is part of the php-code-coverage package.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\Driver;
11+
12+
use SebastianBergmann\CodeCoverage\RuntimeException;
13+
use SebastianBergmann\CodeCoverage\Filter;
14+
15+
/**
16+
* Driver for PCOV code coverage functionality.
17+
*
18+
* @codeCoverageIgnore
19+
*/
20+
final class PCOV implements Driver
21+
{
22+
public function __construct(Filter $filter = null)
23+
{
24+
25+
}
26+
27+
/**
28+
* Start collection of code coverage information.
29+
*/
30+
public function start(bool $determineUnusedAndDead = true): void
31+
{
32+
\pcov\start();
33+
}
34+
35+
/**
36+
* Stop collection of code coverage information.
37+
*/
38+
public function stop(): array
39+
{
40+
\pcov\stop();
41+
42+
$waiting = \pcov\waiting();
43+
$collect = [];
44+
45+
if ($waiting) {
46+
$collect = \pcov\collect(\pcov\inclusive, $waiting);
47+
48+
if ($collect) {
49+
\pcov\clear();
50+
}
51+
}
52+
53+
return $collect;
54+
}
55+
}

tests/tests/CodeCoverageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use SebastianBergmann\CodeCoverage\Driver\Driver;
1313
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
14+
use SebastianBergmann\CodeCoverage\Driver\PCOV;
1415
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
1516
use SebastianBergmann\Environment\Runtime;
1617

0 commit comments

Comments
 (0)