Skip to content

Commit

Permalink
Closes ##4620
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 12, 2021
1 parent 9e9ab4f commit ef1b6b1
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChangeLog-9.5.md
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 9.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

## [9.5.3] - 2021-MM-DD

### Fixed

* [#4620](https://github.com/sebastianbergmann/phpunit/issues/4620): No useful output when an error occurs in the bootstrap script

## [9.5.2] - 2021-02-02

### Fixed
Expand All @@ -28,6 +34,7 @@ All notable changes of the PHPUnit 9.5 release series are documented in this fil

* [#4535](https://github.com/sebastianbergmann/phpunit/issues/4535): `getMockFromWsdl()` does not handle methods that do not have parameters correctly

[9.5.3]: https://github.com/sebastianbergmann/phpunit/compare/9.5.2...9.5
[9.5.2]: https://github.com/sebastianbergmann/phpunit/compare/9.5.1...9.5.2
[9.5.1]: https://github.com/sebastianbergmann/phpunit/compare/9.5.0...9.5.1
[9.5.0]: https://github.com/sebastianbergmann/phpunit/compare/9.4.4...9.5.0
14 changes: 13 additions & 1 deletion src/TextUI/Command.php
Expand Up @@ -20,6 +20,7 @@
use function fgets;
use function file_get_contents;
use function file_put_contents;
use function get_class;
use function getcwd;
use function ini_get;
use function ini_set;
Expand Down Expand Up @@ -560,7 +561,18 @@ protected function handleBootstrap(string $filename): void
try {
FileLoader::checkAndLoad($filename);
} catch (Throwable $t) {
$this->exitWithErrorMessage($t->getMessage());
if ($t instanceof \PHPUnit\Exception) {
$this->exitWithErrorMessage($t->getMessage());
}

$this->exitWithErrorMessage(
sprintf(
'Error in bootstrap script: %s:%s%s',
get_class($t),
PHP_EOL,
$t->getMessage()
)
);
}
}

Expand Down
19 changes: 19 additions & 0 deletions tests/end-to-end/regression/GitHub/4620.phpt
@@ -0,0 +1,19 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/4620
--FILE--
<?php declare(strict_types=1);

$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--bootstrap';
$_SERVER['argv'][] = __DIR__ . '/4620/bootstrap.php';
$_SERVER['argv'][] = __DIR__ . '/4620/Issue4620Test.php';

require __DIR__ . '/../../../bootstrap.php';

PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Error in bootstrap script: PHPUnit\TestFixture\MyException:
Big boom. Big bada boom.
20 changes: 20 additions & 0 deletions tests/end-to-end/regression/GitHub/4620/Issue4620Test.php
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture;

use PHPUnit\Framework\TestCase;

final class Issue4620Test extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}
18 changes: 18 additions & 0 deletions tests/end-to-end/regression/GitHub/4620/bootstrap.php
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture;

use Exception;

final class MyException extends Exception
{
}

throw new MyException('Big boom. Big bada boom.');

0 comments on commit ef1b6b1

Please sign in to comment.