expecto icon indicating copy to clipboard operation
expecto copied to clipboard

Unexpected output format in VSCode terminal

Open markpattison opened this issue 5 years ago • 14 comments

Using VSCode 1.35.1 on Windows 7 with Ionide 4.0.0.

The same issue happens with cmd or powershell terminal options.

To reproduce:

dotnet new -i Expecto.Template::*
dotnet new expecto -n exp
dotnet restore
dotnet run

Actual output (sample):

←[30;1mExpecto Running... ←[1000D←[0m←[?25l←[30;1mExpecto Running... ←[1000D←[0m←[?25l←[30;1mExpecto Running... 3/8 /←[1000D←[0m←[?25l                        ←[1000D←[?25h←[37m[←[37m16:05:35 ←[37mINF←[37m] ←[37mEXPECTO? Running tests...←[37m ←[37m<←[37mExpecto←[37m>←[37m
←[0m←[37m[←[37m16:05:35 ←[31mERR←[37m] ←[36msamples/I'm always fail (should fail)←[37m failed in ←[32m00:00:00.0110000←[37m. ←[36m
This was expected...
   at [email protected](Unit _arg4) in E:\Prog\Source\test\Sample.fs:line 20
   at [email protected](Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expecto.fs:line 939
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)←[37m ←[37m<←[37mExpecto←[37m>←[37m
←[0m←[37m[←[37m16:05:35 ←[31mERR←[37m] ←[36msamples/when true is not (should fail)←[37m failed in ←[32m00:00:00.0110000←[37m. ←[36m
I should fail because the subject is false. Actual value was false but had expected it to be true.
   at [email protected](Unit _arg2) in E:\Prog\Source\test\Sample.fs:line 14
   at [email protected](Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expecto.fs:line 939
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)←[37m ←[37m<←[37mExpecto←[37m>←[37m
←[0m←[37m[←[37m16:05:35 ←[31mERR←[37m] ←[36msamples/contains things (should fail)←[37m failed in ←[32m00:00:00.0350000←[37m. ←[36m

Expected output:

Something like this.

markpattison avatar Jun 30 '19 15:06 markpattison

It looks like the terminal isn't supporting colours for some reason. Not sure why maybe a Windows 7 thing? To work around set --colours 0.

AnthonyLloyd avatar Jun 30 '19 19:06 AnthonyLloyd

The terminal colours do work from FAKE though...

markpattison avatar Jun 30 '19 20:06 markpattison

It must not support ANSI colours and FAKE is using Console.ForegroundColor instead.

Colours are a bit of a pain to support and why we had to put in the --colours option. We could put in and option to use Console colours but they are not atomic and end up with bugs were the colour isn't reset correctly at the end.

AnthonyLloyd avatar Jun 30 '19 20:06 AnthonyLloyd

I would much prefer the check if it's a TTY or "is this Windows", or even "is this running on a super-old Windows". But I don't believe in mutilating the output of this library just so that a decade old operating system can avoid the above issues; especially since you @markpattison could install ANSI colours https://github.com/adoxa/ansicon and have it working.

haf avatar Jun 30 '19 21:06 haf

See https://github.com/haf/expecto/issues/315 for more discussions.

haf avatar Jun 30 '19 21:06 haf

@haf It's such a mess and so difficult to test. I fear checking TTY takes us further down the rabbit hole. It would be good to have a solid example of covering multiple platforms and consoles.

AnthonyLloyd avatar Jun 30 '19 22:06 AnthonyLloyd

@AnthonyLloyd Perhaps then we start with https://docs.microsoft.com/en-us/dotnet/api/system.operatingsystem?view=netframework-4.8 ? Windows can default to 0 colours, otherwise 256?

haf avatar Jul 01 '19 08:07 haf

Same issue in full Visual Studio plugin, makes it unusable :( image

Lanayx avatar Jul 03 '19 21:07 Lanayx

@Lanayx use --colours 0 if that's possible via the plugin

AnthonyLloyd avatar Jul 05 '19 08:07 AnthonyLloyd

@AnthonyLloyd Unfortunately there is no such option there

Lanayx avatar Jul 05 '19 18:07 Lanayx

By the way, I have the same issue as topic starter when running dotnet test on windows 10 in regular console UPD: Also tried dotnet test -- --colours 0 , no effect

Lanayx avatar Jul 05 '19 19:07 Lanayx

@Lanayx I think you need to raise with adamchester/expecto-adapter maybe they should offer config or just set to --colours 0 if VS doesn't support colours. For dotnet test it would be YoloDev/YoloDev.Expecto.TestSdk.

AnthonyLloyd avatar Jul 09 '19 08:07 AnthonyLloyd

There's also a stacktrace from Expecto itself that make it difficult to read. E.g.:

  at [email protected](Unit unitVar)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 398
   at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 1650
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in E:\A\_work\130\s\src\fsharp\FSharp.Core\async.fs:line 109

Michael-McD avatar Dec 10 '19 22:12 Michael-McD

As mentaioned by @haf https://github.com/haf/expecto/issues/331#issuecomment-507163272 ANSICON working fine for me.

To Setup ANSICON:

  1. Download ANSICON
  2. Then rename the folder to ANSICON and move it to C:\
  3. Modify the following in VSCode settings:
{
    ....

     "terminal.integrated.shell.windows": "C:\\Program Files\\ANSICON\\x64\\ansicon.exe",
     "terminal.integrated.shellArgs.windows": [
         "C:\\Program Files\\Git\\bin\\sh.exe",
         "--login",
         "-i"
     ]

}

rajee-a avatar Jun 26 '21 18:06 rajee-a