expecto
expecto copied to clipboard
Unexpected output format in VSCode terminal
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 .
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.
The terminal colours do work from FAKE though...
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.
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.
See https://github.com/haf/expecto/issues/315 for more discussions.
@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 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?
Same issue in full Visual Studio plugin, makes it unusable :(
@Lanayx use --colours 0 if that's possible via the plugin
@AnthonyLloyd Unfortunately there is no such option there
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 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.
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
As mentaioned by @haf https://github.com/haf/expecto/issues/331#issuecomment-507163272 ANSICON working fine for me.
To Setup ANSICON:
- Download ANSICON
- Then rename the folder to ANSICON and move it to C:\
- 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"
]
}