Skip to content

gh-129363: Added colored printing for python -m test without the -j flag #129364

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

Closed
wants to merge 2 commits into from

Conversation

lczyk
Copy link

@lczyk lczyk commented Jan 27, 2025

Fixes #129363. New version based on RunWorkers::display_result.

@bedevere-app
Copy link

bedevere-app bot commented Jan 27, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@lczyk lczyk changed the title gh-129363: Update printing for python -m test without -j flag gh-129363: Added colored printing for python -m test without the -j flag Jan 27, 2025
@ZeroIntensity ZeroIntensity requested a review from hugovk January 29, 2025 01:44
Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

This isn't technically a bug, but does look like an improvement.

Now

Currently, yellow is shown for for skips, red for fail, and green when the time is shown:

image

What's going on is, the name is shown when it begins, and if it takes longer than 30 seconds to run, only then do we print an explicit result (with colour).

Those uncoloured lines are only stating the test started, and we don't show the result.

PR

The PR doesn't only add colour but changes functionality as well. Now it shows the result after it's finished running, and we don't get the uncoloured "start" line:

image

I think this an improvement? It makes it clear the test actually passed.

Comparison

Plus before, we'd get uncoloured .test_processes to show it's started, then when it completes, it prints uncoloured .test_threads to show the next test has started, but then a green .test_processes on the same line to show it's actually finished.

This is a little unclear to have the slow completion report show up after the bit about the next test starting:

image

However, with this PR, we only get the success lines:

image

cc @vstinner as well.

if (
result.duration
and result.duration >= PROGRESS_MIN_TIME
and not self.pgo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why check PGO? I don't think this was relevant before?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike the new behavior. It doesn't show the name of the test currently running. If a test takes 1 minute, for 1 minute, it says nothing. I prefer to know what's going on, which test is running.

I would prefer:

[  1/484] test.test_asyncio.test_base_events
[  1/484] test.test_asyncio.test_base_events passed
[  2/484] test.test_asyncio.test_buffered_proto
[  2/484] test.test_asyncio.test_buffered_proto passed
...

where the second line "passed" is green.

It's more verbose, but it's more explicit what's going on. Especially when a test is stuck.

@vstinner
Copy link
Member

I would prefer: (...)

I wrote PR gh-129476 which does what I want :-) Please have a look.

@vstinner
Copy link
Member

#129476 was merged instead. Thanks for your contribution anyway @MarcinKonowalczyk!

@vstinner vstinner closed this Feb 21, 2025
@lczyk
Copy link
Author

lczyk commented Feb 21, 2025

yup, sorry, fell out the loop on this one. in favour of #129476 ! :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

python -m test color print with and without -j
3 participants