Skip to content

Commit 1fadd25

Browse files
Merge branch '10.5' into 11.5
2 parents 4bc38b1 + 8a90221 commit 1fadd25

File tree

7 files changed

+61
-1
lines changed

7 files changed

+61
-1
lines changed

src/Runner/CodeCoverage.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ public function init(Configuration $configuration, CodeCoverageFilterRegistry $c
116116

117117
$this->deactivate();
118118
}
119+
120+
if (!$configuration->hasCoverageCacheDirectory()) {
121+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
122+
'No cache directory configured, result of static analysis for code coverage will not be cached',
123+
);
124+
}
119125
}
120126

121127
/**

src/TextUI/Output/Default/ResultPrinter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,19 @@ private function printTestRunnerWarnings(TestResult $result): void
183183
}
184184

185185
$elements = [];
186+
$messages = [];
186187

187188
foreach ($result->testRunnerTriggeredWarningEvents() as $event) {
189+
if (isset($messages[$event->message()])) {
190+
continue;
191+
}
192+
188193
$elements[] = [
189194
'title' => $event->message(),
190195
'body' => '',
191196
];
197+
198+
$messages[$event->message()] = true;
192199
}
193200

194201
$this->printListHeaderWithNumber(count($elements), 'PHPUnit test runner warning');

tests/_files/delete_directory.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
function delete_directory(string $directory): void
11+
{
12+
if (\is_file($directory)) {
13+
@\unlink($directory);
14+
15+
return;
16+
}
17+
18+
if (!\is_dir($directory)) {
19+
return;
20+
}
21+
22+
foreach (\glob(\rtrim($directory, '/') . '/*') as $path) {
23+
delete_directory($path);
24+
}
25+
26+
@\rmdir($directory);
27+
}

tests/end-to-end/event/_files/invalid-coverage-metadata/phpunit.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd">
3+
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
4+
cacheDirectory=".phpunit.cache">
45
<testsuites>
56
<testsuite name="default">
67
<directory>tests</directory>

tests/end-to-end/event/invalid-coverage-metadata.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ $_SERVER['argv'][] = '--debug';
1616
require __DIR__ . '/../../bootstrap.php';
1717

1818
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
19+
--CLEAN--
20+
<?php declare(strict_types=1);
21+
require __DIR__ . '/../../_files/delete_directory.php';
22+
23+
delete_directory(__DIR__ . '/_files/invalid-coverage-metadata/.phpunit.cache');
1924
--EXPECTF--
2025
PHPUnit Started (PHPUnit %s using %s)
2126
Test Runner Configured

tests/end-to-end/regression/5218.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ $_SERVER['argv'][] = '--coverage-filter';
1616
$_SERVER['argv'][] = __DIR__ . '/5218/src/';
1717
$_SERVER['argv'][] = '--coverage-text';
1818
$_SERVER['argv'][] = __DIR__ . '/5218/tests/';
19+
$_SERVER['argv'][] = '--cache-directory';
20+
$_SERVER['argv'][] = __DIR__ . '/5218/cache';
1921

2022
require_once __DIR__ . '/../../bootstrap.php';
2123

2224
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
25+
--CLEAN--
26+
<?php declare(strict_types=1);
27+
require __DIR__ . '/../../_files/delete_directory.php';
28+
29+
delete_directory(__DIR__ . '/5218/cache');
2330
--EXPECTF--
2431
PHPUnit %s by Sebastian Bergmann and contributors.
2532

tests/end-to-end/regression/5351.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ $_SERVER['argv'][] = '--colors=never';
1212
$_SERVER['argv'][] = '--coverage-text';
1313
$_SERVER['argv'][] = '--configuration';
1414
$_SERVER['argv'][] = __DIR__ . '/5351/phpunit.xml';
15+
$_SERVER['argv'][] = '--cache-directory';
16+
$_SERVER['argv'][] = __DIR__ . '/5351/cache';
1517

1618
require_once __DIR__ . '/../../bootstrap.php';
1719

1820
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--CLEAN--
22+
<?php declare(strict_types=1);
23+
require __DIR__ . '/../../_files/delete_directory.php';
24+
25+
delete_directory(__DIR__ . '/5351/cache');
1926
--EXPECTF--
2027
PHPUnit %s by Sebastian Bergmann and contributors.
2128

0 commit comments

Comments
 (0)