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 printed when PHPUnit is used from PHAR #4573

Closed
EdmondDantes opened this issue Jan 4, 2021 · 0 comments · Fixed by nextcloud/polls#1475
Closed

No stack trace printed when PHPUnit is used from PHAR #4573

EdmondDantes opened this issue Jan 4, 2021 · 0 comments · Fixed by nextcloud/polls#1475
Assignees
Labels
feature/test-runner CLI test runner installation/phar type/bug Something is broken

Comments

@EdmondDantes
Copy link

$ tree
.
└── tests
└── Test.php

1 directory, 1 file

tests/Test.php

<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class Test extends TestCase
{
    public function testOne(): void
    {
		$phpUnitRoot				= '';
		
		if(defined('__PHPUNIT_PHAR_ROOT__'))
		{
			$phpUnitRoot = __PHPUNIT_PHAR_ROOT__;
		}
		
        throw new \Exception('It\'s error should be displayed with backtrace: '.$phpUnitRoot);
    }
}

Run as phar:

php d:\server\PHP8\phpunit-9.5.0.phar ./tests

output:

D:\www\dev\phpunit_bug>php d:\server\PHP8\phpunit-9.5.0.phar ./tests
PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)


Time: 00:00.003, Memory: 18.00 MB

There was 1 error:

1) Test::testOne
Exception: It's error should be displayed with backtrace: phar://phpunit-9.5.0.p
har

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Expected:

php -f d:\server\PHP8\vendor\phpunit\phpunit\phpunit ./tests

D:\www\dev\phpunit_bug>php -f d:\server\PHP8\vendor\phpunit\phpunit\phpunit ./te
sts
PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)


Time: 00:00.011, Memory: 4.00 MB

There was 1 error:

1) Test::testOne
Exception: It's error should be displayed with backtrace:

D:\www\dev\phpunit_bug\tests\Test.php:15

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Explanation

return $prefix === null &&

Issue:

PHPunit always hide any element of backtrace if launched from phar.

Reason:

Filter::shouldPrintFrame() always returns NULL if PHPUNIT_PHAR_ROOT defined.

Expected behavior:
Backtrace stack output

@sebastianbergmann sebastianbergmann self-assigned this Jan 4, 2021
@sebastianbergmann sebastianbergmann changed the title shouldPrintFrame always returns FALSE for any file in backtrace No stack trace printed when PHPUnit is used from PHAR Jan 27, 2021
This was referenced Mar 12, 2021
This was referenced Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment