Search code examples
haskellghchaskell-stackmingw-w64

Stack test output garbled on MINGW64


I'm running GHC using Stack on Windows 10, and using Git Bash (MINGW64) for much of my daily workflow. That includes using GHC and GHCi, which generally works fine.

However, when I run stack test from MINGW64, the output is garbled by ANSI color codes:

$ stack test
UC-0.1.0.0: test (suite: UC-test)

[?25lSorting Group 1:

[2K[1F  prop1: [[92mOK, passed 100 tests[0m]

[2K[1F  prop2: [[92mOK, passed 100 tests[0m]

         Properties  Total
 Passed  [92m2[0m           [92m2[0m
 Failed  0           0
 Total   [92m2[0m           [92m2[0m
[?25h

Strangely, if I run stack test from the normal Windows console (cmd), it displays correctly:

Correctly coloured test output in cmd

I'd like to stick with my (Git) Bash console instead of having to use two separate console windows, so:

  • Is it possible to get the colours to render correctly for stack test in MINGW64?
  • Alternatively, can I turn off ANSI colouring for stack test, so that, at least, it's easier to read the output?

I've also tried to run variations of stack --color never test, but it doesn't seem to make any difference.


Solution

  • Arguments can be passed to the test executable like this:

    stack test --test-arguments "--plain"
    

    --plain is the option to remove colors in test-framework, while --color never is from tasty.