cylc / cylc-flow

Cylc: a workflow engine for cycling systems.
https://cylc.github.io
GNU General Public License v3.0
335 stars 94 forks source link

Functional test of colour output #6467

Open MetRonnie opened 3 weeks ago

MetRonnie commented 3 weeks ago

There is a problem with this test https://github.com/cylc/cylc-flow/blob/ca454d0032aed567c7913a3f47307c6e5dcaef26/tests/functional/cli/05-colour.t#L34-L35

A color reset char is included on the last line of the output:

Script started on 2024-11-07 18:11:50+00:00 [TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="202" LINES="13"]

Script done on 2024-11-07 18:11:53+00:00 [COMMAND_EXIT_CODE="0"]

This is despite autoreset=False and use_color=False (strip=True) here: https://github.com/cylc/cylc-flow/blob/ca454d0032aed567c7913a3f47307c6e5dcaef26/cylc/flow/terminal.py#L292

Whether this is just some strange interaction between colorama and the script command used in the test, or a bug in colorama, I'm not sure.


N.B. I had a look at how colorama works. It bills itself as a package meant only for making colour work on Windows, but I guess we are using it for its init(strip=not use_color) function that can automatically strip ANSI color chars from print() calls (it actually patches sys.stdout and sys.stderr). However there are >100 open issues and it is in a call-for-maintainers state: https://github.com/tartley/colorama/issues/300.

_Originally posted by @MetRonnie in https://github.com/cylc/cylc-flow/pull/6463#discussion_r1832904014_