diff --git a/src/Runner/Phpt/TestCase.php b/src/Runner/Phpt/TestCase.php index dad0f48f990..5d2bafe2f14 100644 --- a/src/Runner/Phpt/TestCase.php +++ b/src/Runner/Phpt/TestCase.php @@ -27,6 +27,7 @@ use function preg_replace; use function preg_split; use function realpath; +use function sprintf; use function str_contains; use function str_starts_with; use function strncasecmp; @@ -349,6 +350,24 @@ private function shouldTestBeSkipped(array $sections, array $settings): bool $output = $this->runCodeInLocalSandbox($skipIfCode); } + if (str_contains($output, 'Parse error:')) { + EventFacade::emitter()->testRunnerTriggeredPhpunitWarning( + sprintf( + 'SKIPIF section triggered a parse error: %s', + $output, + ), + ); + } + + if (str_contains($output, 'Fatal error:')) { + EventFacade::emitter()->testRunnerTriggeredPhpunitWarning( + sprintf( + 'SKIPIF section triggered a fatal error: %s', + $output, + ), + ); + } + if (strncasecmp('skip', ltrim($output), 4) === 0) { $message = ''; diff --git a/tests/_files/skip-if-requires-code-coverage-driver.php b/tests/_files/skip-if-requires-code-coverage-driver.php index 6d30f0d7ac8..86d8a6c289a 100644 --- a/tests/_files/skip-if-requires-code-coverage-driver.php +++ b/tests/_files/skip-if-requires-code-coverage-driver.php @@ -24,6 +24,8 @@ if (!extension_loaded('xdebug')) { print 'skip: This test requires a code coverage driver'; + + return; } if (version_compare(phpversion('xdebug'), '3.1', '>=') && in_array('coverage', xdebug_info('mode'), true)) { diff --git a/tests/end-to-end/_files/phpt-skipif-invalid-require.phpt b/tests/end-to-end/_files/phpt-skipif-invalid-require.phpt new file mode 100644 index 00000000000..8f1057cd740 --- /dev/null +++ b/tests/end-to-end/_files/phpt-skipif-invalid-require.phpt @@ -0,0 +1,12 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/issues/6311 +--SKIPIF-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +. 1 / 1 (100%) + +Time: %s, Memory: %s + +There was 1 PHPUnit test runner warning: + +1) SKIPIF section triggered a parse error: +Parse error: Unmatched '}' in Standard input code on line 3 + + +OK, but there were issues! +Tests: 1, Assertions: 1, PHPUnit Warnings: 1. diff --git a/tests/end-to-end/regression/6311.phpt b/tests/end-to-end/regression/6311.phpt new file mode 100644 index 00000000000..5b71c2e7453 --- /dev/null +++ b/tests/end-to-end/regression/6311.phpt @@ -0,0 +1,27 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/issues/6311 +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +. 1 / 1 (100%) + +Time: %s, Memory: %s + +There was 1 PHPUnit test runner warning: + +1) SKIPIF section triggered a fatal error: +Warning: require(%afile.php): Failed to open stream: No such file or directory in Standard input code on line %d + +Fatal error: Uncaught Error: Failed opening required%a +%A