From ef1b6b112512788895ad64f167768ce3b4ed166b Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 12 Mar 2021 10:38:44 +0100 Subject: [PATCH] Closes ##4620 --- ChangeLog-9.5.md | 7 +++++++ src/TextUI/Command.php | 14 ++++++++++++- tests/end-to-end/regression/GitHub/4620.phpt | 19 ++++++++++++++++++ .../regression/GitHub/4620/Issue4620Test.php | 20 +++++++++++++++++++ .../regression/GitHub/4620/bootstrap.php | 18 +++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/end-to-end/regression/GitHub/4620.phpt create mode 100644 tests/end-to-end/regression/GitHub/4620/Issue4620Test.php create mode 100644 tests/end-to-end/regression/GitHub/4620/bootstrap.php diff --git a/ChangeLog-9.5.md b/ChangeLog-9.5.md index df61d46c98d..63b9d98d73c 100644 --- a/ChangeLog-9.5.md +++ b/ChangeLog-9.5.md @@ -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 @@ -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 diff --git a/src/TextUI/Command.php b/src/TextUI/Command.php index 4ba761cec2c..e5dd7a01d08 100644 --- a/src/TextUI/Command.php +++ b/src/TextUI/Command.php @@ -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; @@ -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() + ) + ); } } diff --git a/tests/end-to-end/regression/GitHub/4620.phpt b/tests/end-to-end/regression/GitHub/4620.phpt new file mode 100644 index 00000000000..0845a9f44ae --- /dev/null +++ b/tests/end-to-end/regression/GitHub/4620.phpt @@ -0,0 +1,19 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/issues/4620 +--FILE-- + + * + * 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); + } +} diff --git a/tests/end-to-end/regression/GitHub/4620/bootstrap.php b/tests/end-to-end/regression/GitHub/4620/bootstrap.php new file mode 100644 index 00000000000..1ebcc1818a1 --- /dev/null +++ b/tests/end-to-end/regression/GitHub/4620/bootstrap.php @@ -0,0 +1,18 @@ + + * + * 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.');