thoth-org/Thoth.Json.Net

Tests not working on master when run on Windows

Closed this issue · 13 comments

forki commented

image

I seee 36 test errors on master

There is really something wrong with Windows...

I guess it's again the linefeed char that causing a problem but the fix we included last time for it is still here... Source

Can you please show me 1-2 failing test output. If possible using code block and not screenshot (I can't copy/paste screenshot)?

And I guess I need to find a way to access a windows machine or VM in order to explore the reasons being the failing tests...

forki commented

yes it looks like some linebreak issue:


[14:12:07 ERR] All/Thoth.Json.Decode/Inconsistent structure/optional returns Error value if decoder fails failed in 00:00:00.0020000.
.
expected:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
  actual:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1129-194.Invoke(Unit _arg71) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1141
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/Fancy decoding/andThen generate an error if an error occuered failed in 00:00:00.0020000.
.
expected:
Error
  "Error at: `$`
Expecting an object with a field named `version` but instead got:
{
    "info": 3,
    "data": 2
}"
  actual:
Error
  "Error at: `$`
Expecting an object with a field named `version` but instead got:
{
    "info": 3,
    "data": 2
}"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1349-237.Invoke(Unit _arg80) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1376
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/Inconsistent structure/combining field and
option decoders works failed in 00:00:00.0380000.
. String does not match at position 18. Expected char: '\013', but got '\010'.
expected:
Error at: `$.name`
Expecting an int but instead got: "maxime"
  actual:
Error at: `$.name`
Expecting an int but instead got: "maxime"
   at Expecto.Expect.stringEquals@271-5.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 271
   at Expecto.Expect.stringEquals[a](IEnumerable`1 actual, IEnumerable`1 expected, String message) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line
269
   at Tests.Decode.tests@1168-202.Invoke(Unit _arg73) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1187
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Required.Field returns Error if type is incorrect failed in 00:00:00.0020000.
.
expected:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
  actual:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1586-249.Invoke(Unit _arg92) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1604
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Optional.Field returns Error value if decoder fails failed in 00:00:00.0030000.
.
expected:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
  actual:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1651-253.Invoke(Unit _arg96) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1665
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Required.Field returns Error if field is missing failed in 00:00:00.0030000.
.
expected:
Error
  "Error at: `$`
Expecting an object with a field named `name` but instead got:
{
    "age": 25
}"
  actual:
Error
  "Error at: `$`
Expecting an object with a field named `name` but instead got:
{
    "age": 25
}"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1563-248.Invoke(Unit _arg91) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1584
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Required.At returns Error if type is incorrect failed in 00:00:00.0050000.
.
expected:
Error "Error at: `$.user.name`
Expecting a string but instead got: 12"
  actual:
Error "Error at: `$.user.name`
Expecting a string but instead got: 12"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1777-259.Invoke(Unit _arg102) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1795
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Optional.Field returns Error if type is incorrect failed in 00:00:00.0030000.
.
expected:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
  actual:
Error "Error at: `$.name`
Expecting a string but instead got: 12"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1692-255.Invoke(Unit _arg98) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1710
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Required.At returns Error if non-object in path failed in 00:00:00.0050000.
.
expected:
Error "Error at: `$.user`
Expecting an object but instead got:
"maxime""
  actual:
Error "Error at: `$.user`
Expecting an object but instead got:
"maxime""
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1729-257.Invoke(Unit _arg100) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1748
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Optional.At returns 'type error' if non-object in path failed in 00:00:00.0040000.
.
expected:
Error "Error at: `$.user`
Expecting an object but instead got:
"maxime""
  actual:
Error "Error at: `$.user`
Expecting an object but instead got:
"maxime""
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1813-261.Invoke(Unit _arg104) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1833
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Required.At returns Error if field missing failed in 00:00:00.0050000.
.
expected:
Error
  "Error at: `$.user.firstname`
Expecting an object with path `user.firstname` but instead got:
{
    "user": {
        "name": "maxime",
        "age": 25
    }
}
Node `firstname` is unkown."
  actual:
Error
  "Error at: `$.user.firstname`
Expecting an object with path `user.firstname` but instead got:
{
    "user": {
        "name": "maxime",
        "age": 25
    }
}
Node `firstname` is unkown."
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1750-258.Invoke(Unit _arg101) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1775
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Optional.At returns Error if type is incorrect failed in 00:00:00.0040000.
.
expected:
Error "Error at: `$.user.name`
Expecting a string but instead got: 12"
  actual:
Error "Error at: `$.user.name`
Expecting a string but instead got: 12"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1850-263.Invoke(Unit _arg106) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1868
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/get.Field.Raw returns Error
if a field is missing in the 'raw decoder' failed in 00:00:00.0080000.
.
expected:
Error
  "Error at: `$`
Expecting an object with a field named `radius` but instead got:
{
    "enabled": true,
    "shape": "circle"
}"
  actual:
Error
  "Error at: `$`
Expecting an object with a field named `radius` but instead got:
{
    "enabled": true,
    "shape": "circle"
}"
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@1956-267.Invoke(Unit _arg110) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 1992
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 ERR] All/Thoth.Json.Decode/object builder/Object builders returns all
the Errors failed in 00:00:00.0110000.
.
expected:
Error
  "I run into the following problems:

Error at: `$`
Expecting an object with a field named `missing_field_1` but instead got:
{
    "age": 25,
    "fieldC": "not_a_number",
    "fieldD": {
        "sub_field": "not_a_boolean"
    }
}

Error at: `$.missing_field_2.sub_field`
Expecting an object with path `missing_field_2.sub_field` but instead got:
{
    "age": 25,
    "fieldC": "not_a_number",
    "fieldD": {
        "sub_field": "not_a_boolean"
    }
}
Node `sub_field` is unkown.

Error at: `$.fieldC`
Expecting an int but instead got: "not_a_number"

Error at: `$.fieldD.sub_field`
Expecting a boolean but instead got: "not_a_boolean""
  actual:
Error
  "I run into the following problems:

Error at: `$`
Expecting an object with a field named `missing_field_1` but instead got:
{
    "age": 25,
    "fieldC": "not_a_number",
    "fieldD": {
        "sub_field": "not_a_boolean"
    }
}

Error at: `$.missing_field_2.sub_field`
Expecting an object with path `missing_field_2.sub_field` but instead got:
{
    "age": 25,
    "fieldC": "not_a_number",
    "fieldD": {
        "sub_field": "not_a_boolean"
    }
}
Node `sub_field` is unkown.

Error at: `$.fieldC`
Expecting an int but instead got: "not_a_number"

Error at: `$.fieldD.sub_field`
Expecting a boolean but instead got: "not_a_boolean""
   at Expecto.Expect.equal@323-7.Invoke(String x) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Expecto.Expect.equal$cont@305[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 323
   at Tests.Decode.tests@2154-273.Invoke(Unit _arg116) in D:\code\Thoth.Json.Net\paket-files\thoth-org\Thoth.Json\tests\Tests.Json.Decode.fs:line 2202
   at Expecto.Impl.execTestAsync@932-1.Invoke(Unit unitVar) in C:\Users\Anthony
Lloyd\src\expecto\Expecto\Expecto.fs:line 936
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) <Expecto>
[14:12:07 INF] EXPECTO! 190 tests run in 00:00:00.7262640 for All - 154 passed,
0 ignored, 36 failed, 0 errored.  <Expecto>
Finished (Failed) 'Test' in 00:00:25.7145375

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target          Duration
------          --------
Clean           00:00:00.0467861
YarnInstall     00:00:00.5589381
DotnetRestore   00:00:10.1967298
AdaptTest       00:00:00.0180233
Test            00:00:25.7140442   (Expecto for netcore tests failed.)
Total:          00:00:36.6825489
Status:         Failure ``` 

Ok, so the CI from Azure seems to confirm the "new line" problem.

We see a lot of 5m at end of the line which I suspect it's representing a special newline char.

Now, we need a way to ensure the encoding / chars used.

Ok, small update.

I know how to fix tests for windows... We are at 12 failed instead of 36 failed now. I should fix the rest this evening

In the end my solution doesn't work...

I wasn't really fond of it but it was:

/// This function is needed because Windows is messing up the EOL
/// and breaks the tests when running against .NET / .NET Core
let normalizeEOL (txt : string) =
    txt
        .Replace("\r\n", "\n")
        .Replace("\r", "\n")
        .Trim()

So basically, fixing manually the EOL characters manually but it seems there is also some problems with \ characters.

From what I see we have:

  • EOL | new line represented using [32m or [31m
  • \ represented using \010 or \013
  • And some really strange encoding in the string like:
"NOT A TimeSpan�[36m"�[32m"�[36m
"NOT A TimeSpan"�[36m"

I don't understand why .NET or .NET Core are not using the same Encoding for the string generated by Newtonsoft or the strings coming directly from the test files...

Is it possible that """ """ escaped string are changing the encoding behavior?...

Hello @toburger ,

in the past you were able to help me fix the encoding issues when running the Unit test on Windows MangelMaxime/Thoth#26.

It seems we have again an encoding issue. Do you have an idea on how to fix it?

I saw today that in Giraffe, we are using let Utf8EncodingWithoutBom = new UTF8Encoding(false) for the encoding. Perhaps, we could use it inside Thoth.Json.Net too because I have some old (really old) memories that are relating to the Bom thingy.

forki commented

is it related to using paket files?

Fuck it is...

Last commit is green: #6

So paket is writing the files in a "particular" way 🤔

It's also possible that it's not paket fault.

In the AdaptTest target, I am rewriting the file. I am trying to explore the detected Encoding between the different platform and see if I can solve the problem by specifying a common encoding for all of them.

It looks like paket-files\thoth-org\Thoth.Json\tests\Decoders.fs ended up as CRLF on disk on Windows so the hardcoded triple quoted strings aren't correctly compared. I could verify changing that file to LF caused dotnet run to pass

@johlrich Ah yes, thank you for the track. 🙏

In the end, the problem was because I was using File.write from Fake and I think it's using native EOL char so CRLF under windows.

I adapted the script to:

|> String.concat "\n"
|> File.writeString false path

Like that, I know which EOL char is used while writing the file.