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

Test output should be coloured even when run simultaneously #9388

Closed
chris-morgan opened this issue Sep 21, 2013 · 7 comments
Closed

Test output should be coloured even when run simultaneously #9388

chris-morgan opened this issue Sep 21, 2013 · 7 comments

Comments

@chris-morgan
Copy link
Member

At present, test output is done without colour1 unless RUST_TEST_TASKS is 1. On supported operating systems, colour should always be done, regardless of the value of RUST_TEST_TASKS.

On a normal OS, you're just writing the likes of testing foo... ^[[4mok^[[0m\n, so I don't see what can go wrong with the formatting, assuming it's being done as one write call.

Windows might have race conditions here on account of its make-an-API-call approach; I don't know. (Is it even supported for colouring?) But that's no reason to hold back the Dazzling Glory of Useful Colours from the proletariat 2.


1 "color", for those of you who speak en_US.

2 Something tells me the proletariat wouldn't be running Rust tests. Too bad. That's his fault, not mine.

@alexcrichton
Copy link
Member

My understanding is that they're disabled for the reason you mentioned, color emission isn't one write call, but rather three (start, content, end). Because it's not one call to write, the output can get interleaved, causing "interesting" output in parallel tests.

Although I'm perfectly ok with string concatenation to have one call to write.

@Kimundi
Copy link
Member

Kimundi commented Sep 21, 2013

Couldn't the test runner simply be a single-task manager for running all the tests, receiving an message on success/failure and writing that to stdout sequentially?
The only thing that could corrupt the output then would be if the tests themselves write to stdout/stderr. Could those two be redirected per-task and piped to the test runner to be printed sequentially too?

@brson
Copy link
Contributor

brson commented Sep 21, 2013

@Kimundi that's exactly right that the problem is that the tests themselves are outputing to stdout and that corrupts the colors printed by the test runner. Redirecting stdout per task would require the stdio types to be questionably sophisticated. A less-controversial approach might be to simply make logging redirectable per-task and not let tests use stdio directly at all.

Perhaps as @chris-morgan mentioned the term code is doing something silly and splitting the escape codes across writes, but that would be kind of suprprising.

@jdm
Copy link
Contributor

jdm commented Sep 22, 2013

See #782.

@gifnksm
Copy link
Contributor

gifnksm commented Jan 20, 2014

Can std::io::LineBufferedWriter guarantee that the write is called only once per line?
I try this idea, and I'll make PR if this goes well.

@treeman
Copy link
Contributor

treeman commented Sep 15, 2014

Dup of #782?

@alexcrichton
Copy link
Member

Yes, thanks @treeman

Jarcho pushed a commit to Jarcho/rust that referenced this issue Aug 29, 2022
Rustup

Hopefully this is done right.

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

No branches or pull requests

7 participants