Skip to content

Commit c5c7c9d

Browse files
committed
move test into new CI job
1 parent 54f195f commit c5c7c9d

File tree

6 files changed

+124
-7
lines changed

6 files changed

+124
-7
lines changed

.github/workflows/ci.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,73 @@ jobs:
196196
- name: Run tests with PHPUnit
197197
run: php ./phpunit --testsuite end-to-end --order-by depends,random
198198

199+
end-to-end-tests-with-coverage-driver:
200+
name: End-to-End Tests
201+
202+
needs:
203+
- unit-tests
204+
205+
runs-on: ${{ matrix.os }}
206+
timeout-minutes: 5
207+
208+
env:
209+
PHP_EXTENSIONS: none, ctype, curl, dom, json, libxml, mbstring, openssl, pdo, phar, tokenizer, xml, xmlwriter
210+
PHP_INI_VALUES: zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
211+
212+
strategy:
213+
fail-fast: false
214+
matrix:
215+
os:
216+
- ubuntu-latest
217+
- windows-latest
218+
219+
php-version:
220+
- "8.3"
221+
- "8.4"
222+
- "8.5"
223+
224+
steps:
225+
- name: Configure Git to avoid issues with line endings
226+
if: matrix.os == 'windows-latest'
227+
run: git config --global core.autocrlf false
228+
229+
- name: Checkout
230+
uses: actions/checkout@v4
231+
with:
232+
fetch-depth: 0
233+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
234+
235+
- name: Use local branch
236+
shell: bash
237+
run: |
238+
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
239+
git branch -D $BRANCH 2>/dev/null || true
240+
git branch $BRANCH HEAD
241+
git checkout $BRANCH
242+
243+
- name: Install PHP with extensions
244+
uses: shivammathur/setup-php@v2
245+
with:
246+
coverage: xdebug
247+
php-version: ${{ matrix.php-version }}
248+
extensions: ${{ env.PHP_EXTENSIONS }}
249+
ini-values: ${{ env.PHP_INI_VALUES }}
250+
tools: none
251+
252+
- name: Install dependencies with Composer
253+
run: php ./tools/composer install --no-ansi --no-interaction --no-progress
254+
255+
- name: Run tests with PHPUnit
256+
run: php ./phpunit --testsuite end-to-end-with-coverage-driver --order-by depends,random
257+
199258
code-coverage:
200259
name: Code Coverage
201260

202261
if: github.event_name != 'schedule'
203262

204263
needs:
205264
- end-to-end-tests
265+
- end-to-end-tests-with-coverage-driver
206266

207267
runs-on: ubuntu-latest
208268
timeout-minutes: 10

phpunit.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<exclude>tests/end-to-end/self-direct-indirect/_files</exclude>
4848
<exclude>tests/end-to-end/testdox/_files</exclude>
4949
</testsuite>
50+
51+
<testsuite name="end-to-end-with-coverage-driver">
52+
<directory suffix=".phpt">tests/end-to-end-with-coverage-driver/warn-when-opcache-enabled</directory>
53+
</testsuite>
5054
</testsuites>
5155

5256
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
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 PHPUnit\TestFixture\CoverageWithOpcacheEnabled;
11+
12+
final class Greeter
13+
{
14+
public function greet(): string
15+
{
16+
return 'Hello world!';
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of PHPUnit.
5+
*
6+
* (c) Sebastian Bergmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
require_once __DIR__ . '/Greeter.php';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
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 PHPUnit\TestFixture\CoverageWithOpcacheEnabled;
11+
12+
use PHPUnit\Framework\Attributes\CoversClass;
13+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
14+
use PHPUnit\Framework\Attributes\Ticket;
15+
use PHPUnit\Framework\TestCase;
16+
17+
#[CoversClass(Greeter::class)]
18+
final class GreeterTest extends TestCase
19+
{
20+
public function testGreets(): void
21+
{
22+
$this->assertSame('Hello world!', (new Greeter)->greet());
23+
}
24+
25+
}

tests/end-to-end/phar/tests/phpt/warn-when-opcache-enabled.phpt renamed to tests/end-to-end-with-coverage-driver/warn-when-opcache-enabled/warn-when-opcache-enabled.phpt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ https://github.com/sebastianbergmann/php-code-coverage/issues/1022
33
--INI--
44
opcache.enable_cli=1
55
opcache.jit=disable
6-
pcov.directory=tests/end-to-end/phar/src/
76
--SKIPIF--
87
<?php declare(strict_types=1);
9-
require __DIR__ . '/../../_files/skip-if-requires-code-coverage-driver.php';
8+
require __DIR__ . '/../_files/skip-if-requires-code-coverage-driver.php';
109

1110
if (!function_exists('opcache_compile_file')) {
1211
echo 'skip, opcache extension is not loaded';
@@ -19,12 +18,12 @@ $_SERVER['argv'][] = '--do-not-cache-result';
1918
$_SERVER['argv'][] = '--colors=never';
2019
$_SERVER['argv'][] = '--coverage-text';
2120
$_SERVER['argv'][] = '--bootstrap';
22-
$_SERVER['argv'][] = __DIR__.'/../../src/autoload.php';
21+
$_SERVER['argv'][] = __DIR__.'/src/autoload.php';
2322
$_SERVER['argv'][] = '--coverage-filter';
24-
$_SERVER['argv'][] = __DIR__.'/../../src/';
25-
$_SERVER['argv'][] = __DIR__.'/../standard/GreeterTest.php';
23+
$_SERVER['argv'][] = __DIR__.'/src/';
24+
$_SERVER['argv'][] = __DIR__.'/tests/GreeterTest.php';
2625

27-
require_once __DIR__ . '/../../../../bootstrap.php';
26+
require_once __DIR__ . '/../../bootstrap.php';
2827

2928
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
3029
--EXPECTF--
@@ -33,7 +32,7 @@ PHPUnit %s by Sebastian Bergmann and contributors.
3332
Runtime: %s
3433
Configuration: %s
3534

36-
.. 2 / 2 (100%)
35+
. 1 / 1 (100%)
3736

3837
Time: %s, Memory: %s MB
3938

0 commit comments

Comments
 (0)