Skip to content

Commit

Permalink
Ensure the directory for --dump-xdebug-filter exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jan 15, 2019
1 parent 3328623 commit 1a5c898
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use PHPUnit\Runner\TestSuiteSorter;
use PHPUnit\Runner\Version;
use PHPUnit\Util\Configuration;
use PHPUnit\Util\Filesystem;
use PHPUnit\Util\Log\JUnit;
use PHPUnit\Util\Log\TeamCity;
use PHPUnit\Util\Printer;
Expand Down Expand Up @@ -562,11 +563,18 @@ public function doRun(Test $suite, array $arguments = [], bool $exit = true): Te
}

if (isset($arguments['xdebugFilterFile'], $filterConfiguration)) {
$this->write("\n");

$script = (new XdebugFilterScriptGenerator)->generate($filterConfiguration['whitelist']);

if (!Filesystem::createDirectory(\dirname($arguments['xdebugFilterFile']))) {
$this->write(\sprintf('Cannot write Xdebug filter script to %s ' . \PHP_EOL, $arguments['xdebugFilterFile']));

exit(self::EXCEPTION_EXIT);
}

\file_put_contents($arguments['xdebugFilterFile'], $script);

$this->write("\n");
$this->write(\sprintf('Wrote Xdebug filter script to %s ' . \PHP_EOL, $arguments['xdebugFilterFile']));

exit(self::SUCCESS_EXIT);
Expand Down
1 change: 1 addition & 0 deletions tests/end-to-end/dump-xdebug-filter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

<?php declare(strict_types=1);
if (!\function_exists('xdebug_set_filter')) {
return;
Expand Down

0 comments on commit 1a5c898

Please sign in to comment.