-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Text coverage report no longer shows colours #5881
Comments
Thank you for your report. Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue. |
I think it is less about the test case and more about the environment. I was able to get it to work in WSL 2 (Ubuntu), but it does not work in GitHub Actions and it does not work in Git Bash (mintty) on Windows. Perhaps you are doing some (invalid) terminal capability detection that concludes these environments do not support colours even though they do. Again, this worked in PHPUnit 9 and earlier; it is only broken in PHPUnit 10. |
I am sorry to say this, but this report is not actionable for me. I cannot and will not work on this myself, as I do not know how. I somebody, maybe you, finds the cause for this issue in their environment and sends a pull request then I will, of course, consider that. |
Cannot = false. Will not = noted. You have access to GitHub Actions, same as me. Nevertheless, I'll try to get to the bottom of it myself. Alone. |
Terminal capabilities are checked by Looking at sebastianbergmann/environment@5.1.5...6.1.0#files_bucket, I do not see any code changes between the version used by PHPUnit 9 and PHPUnit 10 that are related to detecting terminal capabilities. https://github.com/sebastianbergmann/environment/blob/5.1.5/src/Console.php#L55-L77 and https://github.com/sebastianbergmann/environment/blob/6.1.0/src/Console.php#L55-L77 are identical, AFAICS. |
Setting |
Looks like the original code in Symfony Console that I copied/adapted has changed. It now looks like so. However, that does not explain the difference between PHPUnit 9 and PHPUnit 10 in your environment. |
At some point (somewhat recently) I manually changed the TERM setting from EDIT: No, it doesn't (what am I saying?) The fact of the matter is, |
I think a valid question would be, why does PHPUnit even attempt to do capabilities detection when
Further, the whole notion of capabilities detection seems somewhat of a nonsense because all the escapes are hardcoded anyway; it's not like we're pulling the correct escapes from a term capabilities database (as should be done if we're being strictly correct). GitHub Actions environment is a tricky case because it does not behave like a valid terminal environment supporting colour, yet it does support it anyway. Correct colour capabilities detection (e.g. using |
Although I haven't been able to step debug/trace it, it seems clear from this behaviour that in PHPUnit 9, whether due to a bug or otherwise, capabilities simply weren't being checked. In PHPUnit 10, whether internally or otherwise, capabilities are now being consulted before outputting colours, as we can see by colours now being disabled when the (limited) environment detection kicks in for unsupported environments. Therefore, looking for changes in the code for capabilities support is a red herring, because in the previous version, capabilities support wasn't even being consulted at all. I still think the previous behaviour was correct. If we want to do environment detection, a new |
To get colour support back in all environments, (i.e. the old PHPUnit 9 behaviour) was must set "scripts": {
"test": ["@putenv TERM_PROGRAM=Hyper", "phpunit"],
} This covers off Windows and GitHub Actions environments equally. |
What are we going to do about this? Just copy/paste the updated code, or try to convince them to make this code public? |
@Bilge Thanks for your solution, it helps me to re-introduced PHPUnit code coverage feature that I've not used since a long time. And it works well on GitHub Actions and WSL 2 (for my locally tests) on PHPUnit 10.5 ! TL;DR but more details (with screenshots) are given at llaville/box-manifest#12 |
Summary
PHPUnit 9
--coverage-text
withcolors="true"
would output the report in colour, making it easy to identify which files were uncovered. PHPUnit 10 does not do this.Current behavior
Colours are gone 😞
How to reproduce
phpunit --coverage-text
Expected behavior
Colours.
The text was updated successfully, but these errors were encountered: