Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No stack trace shown for previous exceptions during bootstrap #5345

Closed
Steveb-p opened this issue Apr 24, 2023 · 0 comments
Closed

No stack trace shown for previous exceptions during bootstrap #5345

Steveb-p opened this issue Apr 24, 2023 · 0 comments
Labels
type/bug Something is broken version/9 Something affects PHPUnit 9

Comments

@Steveb-p
Copy link
Contributor

Steveb-p commented Apr 24, 2023

Q A
PHPUnit version 9.6.7
PHP version 7.4.33
Installation Method Composer

Summary

I had a situation where the actual error during bootstrap was hidden inside an exception set as $previous, leaving me with only a vague general error (that was coming from my own code, but the actual error with proper stacktrace was inside).

This follows up on #4877 and #4878.

No idea if the behavior is changed for PHPUnit 10.

Current behavior

Currently errors during bootstrap do print stacktrace, but only from the top-most exception.

 Error in bootstrap script: PHPUnit\TestFixture\MyException:
 Big boom. Big bada boom.
 #0 /home/pniedzielski/PhpstormProjects/phpunit/src/Util/FileLoader.php(66): include_once()
 #1 /home/pniedzielski/PhpstormProjects/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
 #2 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(565): PHPUnit\Util\FileLoader::checkAndLoad()
 #3 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(402): PHPUnit\TextUI\Command->handleBootstrap()
 #4 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(112): PHPUnit\TextUI\Command->handleArguments()
 #5 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(97): PHPUnit\TextUI\Command->run()
 #6 Standard input code(11): PHPUnit\TextUI\Command::main()
 #7 {main}

How to reproduce

Create a bootstrap file that throws an exception with the 3rd argument ($previous) filled with yet another exception.

Expected behavior

Ideally, the previous exceptions stacktrace is printed out, until we reach the end of the "exception stack".

Something along the lines of:

 Error in bootstrap script: PHPUnit\TestFixture\MyException:
 Big boom. Big bada boom.
 #0 /home/pniedzielski/PhpstormProjects/phpunit/src/Util/FileLoader.php(66): include_once()
 #1 /home/pniedzielski/PhpstormProjects/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
 #2 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(565): PHPUnit\Util\FileLoader::checkAndLoad()
 #3 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(402): PHPUnit\TextUI\Command->handleBootstrap()
 #4 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(112): PHPUnit\TextUI\Command->handleArguments()
 #5 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(97): PHPUnit\TextUI\Command->run()
 #6 Standard input code(11): PHPUnit\TextUI\Command::main()
 #7 {main}
 
 Previous exception: Exception:
 Previous boom.
 #0 /home/pniedzielski/PhpstormProjects/phpunit/src/Util/FileLoader.php(66): include_once()
 #1 /home/pniedzielski/PhpstormProjects/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
 #2 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(565): PHPUnit\Util\FileLoader::checkAndLoad()
 #3 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(402): PHPUnit\TextUI\Command->handleBootstrap()
 #4 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(112): PHPUnit\TextUI\Command->handleArguments()
 #5 /home/pniedzielski/PhpstormProjects/phpunit/src/TextUI/Command.php(97): PHPUnit\TextUI\Command->run()
 #6 Standard input code(11): PHPUnit\TextUI\Command::main()
 #7 {main}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken version/9 Something affects PHPUnit 9
Projects
None yet
Development

No branches or pull requests

2 participants