Skip to content

RUST_TEST_TASKS=1 colors output when stdout is not a tty #14570

@bnoordhuis

Description

@bnoordhuis

Apologies if this has been reported before. It's a minor issue for sure but here goes:

$ echo ' #[test] fn test() {}' | rustc --test -o t -

$ env RUST_TEST_TASKS=1 ./t | xxd  # contains escape codes
0000000: 0a72 756e 6e69 6e67 2031 2074 6573 740a  .running 1 test.
0000010: 7465 7374 2074 6573 7420 2e2e 2e20 1b5b  test test ... .[
0000020: 3332 6d6f 6b1b 5b6d 0f0a 0a74 6573 7420  32mok.[m...test 
0000030: 7265 7375 6c74 3a20 1b5b 3332 6d6f 6b1b  result: .[32mok.
0000040: 5b6d 0f2e 2031 2070 6173 7365 643b 2030  [m.. 1 passed; 0
0000050: 2066 6169 6c65 643b 2030 2069 676e 6f72   failed; 0 ignor
0000060: 6564 3b20 3020 6d65 6173 7572 6564 0a0a  ed; 0 measured..

$ env RUST_TEST_TASKS=2 ./t | xxd  # clean
0000000: 0a72 756e 6e69 6e67 2031 2074 6573 740a  .running 1 test.
0000010: 7465 7374 2074 6573 7420 2e2e 2e20 6f6b  test test ... ok
0000020: 0a0a 7465 7374 2072 6573 756c 743a 206f  ..test result: o
0000030: 6b2e 2031 2070 6173 7365 643b 2030 2066  k. 1 passed; 0 f
0000040: 6169 6c65 643b 2030 2069 676e 6f72 6564  ailed; 0 ignored
0000050: 3b20 3020 6d65 6173 7572 6564 0a0a       ; 0 measured..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions