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

The path passed to --log-events-text or --log-events-verbose-text must be absolute #5608

Closed
theofidry opened this issue Dec 10, 2023 · 3 comments
Labels
type/bug Something is broken version/10 Something affects PHPUnit 10

Comments

@theofidry
Copy link
Contributor

Q A
PHPUnit version 10.5.2
PHP version 8.3.0
Installation Method Composer

Summary

When executing PHPUnit with --log-events-text or --log-events-verbose-text, the configured path may not be absolute. In this case, if a test changes the working directory, the output file may inadvertently change.

Current behavior

In Box:

$ php -dphar.readonly=1 vendor/bin/phpunit --testsuite=Tests --colors=always tests/Console/Command --log-events-text=dist/log-phpunit

[...]

Warning: file_put_contents(dist/log2): Failed to open stream: No such file or directory in /Users/tfidry/Project/Humbug/box/vendor/phpunit/phpunit/src/Logging/EventLogger.php on line 43

Call Stack:
    0.0001     633832   1. {main}() /Users/tfidry/Project/Humbug/box/vendor/bin/phpunit:0
    0.0002     645504   2. include('/Users/tfidry/Project/Humbug/box/vendor/phpunit/phpunit/phpunit') /Users/tfidry/Project/Humbug/box/vendor/bin/phpunit:122
    0.0162    7193032   3. PHPUnit\TextUI\Application->run($argv = [0 => 'vendor/bin/phpunit', 1 => '--testsuite=Tests', 2 => '--colors=always', 3 => 'tests/Console/Command', 4 => '--log-events-text=dist/log2']) /Users/tfidry/Project/Humbug/box/vendor/phpunit/phpunit/phpunit:99

[...]

How to reproduce

Expected behavior

The path pased, e.g. dist/log-phpunit, should probably be evaluated as $(pwd)/dist/log-phpunit before any test is executed so that it may not change due to a test/extension changing the working directory in a weird place.

@theofidry theofidry added type/bug Something is broken version/10 Something affects PHPUnit 10 labels Dec 10, 2023
@sebastianbergmann sebastianbergmann changed the title The path passed to --log-events-text or --log-events-verbose-text must be absolute The path passed to --log-events-text or --log-events-verbose-text must be absolute Dec 10, 2023
@sebastianbergmann
Copy link
Owner

the configured path may not be absolute

You mean "the configured path may not be relative", right?

@theofidry
Copy link
Contributor Author

You mean "the configured path may not be relative", right?

No, if the path configured is absolute you would not have an issue as even if the working directory changes it will not change.

@marac19901990
Copy link
Contributor

marac19901990 commented Dec 31, 2023

#5633 Here is a pull request with the changes needed.

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/10 Something affects PHPUnit 10
Projects
None yet
Development

No branches or pull requests

3 participants