haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

Reported error is unreadable in TeamCity #309

Closed otto-gebb closed 5 years ago

otto-gebb commented 5 years ago

When a test fails in TeamCity the test summary is hard to read, see the screenshot below:

image

AnthonyLloyd commented 5 years ago

Thanks. Ill take a look. I'm looking at colours in edge cases for another issue.

haf commented 5 years ago

The solution here is to check whether the the terminal is in tty mode; if it is, allow colours, otherwise, don't. It's not about the colours themselves. @AnthonyLloyd https://github.com/stedolan/jq/blob/dffba62e131588dd1400c37fa3ec0dff2375f35f/src/main.c#L552-L556

haf commented 5 years ago

https://stackoverflow.com/questions/36258224/what-is-isatty-in-c-for

haf commented 5 years ago

https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs#L436-L446

AnthonyLloyd commented 5 years ago

@haf Is there a cross platform way of doing this? I can't find much on google.

jzabroski commented 5 years ago

@AnthonyLloyd @haf Sorry, what's unreadable here? It looks like a typical unit test actual/expected output. I guess I think the terminal detection is neither here nor there.

As for cross platform isatty(), Unity Engine ran giant regression suite on TeamCity for a very long time using Mono on Linux, and were TeamCity largest client for a long time until switching, so I'd be surprised if there wasn't a reliable way to detect this.

jzabroski commented 5 years ago

@otto-gebb What would make this easier to read?

AnthonyLloyd commented 5 years ago

@jzabroski The output is corrupt by colour codes. Only 1 and 5 should show.

I've added a --colours config option. This can be set to --colours 0 to turn off colouring completely.