Fix tests on Windows#8747
Conversation
|
|
||
| // assert | ||
| Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
| response.Headers.Remove("ETag"); |
There was a problem hiding this comment.
ETag and ContentLength differ based on whether the response contains \n or \r\n as new line delimiter. I removed them as I think these values are out-of-scope for the actual test case.
glen-84
left a comment
There was a problem hiding this comment.
This is okay for now, though I am considering changing the approach.
Are you using LF or CRLF on Windows? I'm using LF (no autocrlf, etc.), but I'm wondering whether it might simplify things if I checked out CRLF and committed LF.
|
@glen-84 I use LF with no autocrlf. Using CRLF with autocrlf opens a different can of worms (I tried it out) as that implicitly changes all multi-line raw string literals. This will change f. e. the operation hash of such operations, causing a few (around 10 or so) other tests to fail. Anyhow, I do not see a single change here that shouldn't be required for CRLF-environments. If any, such environments will require additional adjustments. |
Ya, this is a pain, but if we decided that operation hashes should vary depending on platform (not sure about this), then one option would be to scrub hashes from the snapshots.
We wouldn't need the special handling in the CookieCrumble Snapshot class, or any of the |
Probably it would indeed be beneficial to have a linefeed-agnostic hash: If I recall correctly, the foo(arg: "abc") { \n
p1 { \n
bar \n
} \n
} \nis indeed identical to: foo(arg: "abc") { \r\n
p1 { \r\n
bar \r\n
} \r\n
} \r\nbut foo(arg: "a\nb\nc\n") { \n
p1 { \n
bar \n
} \n
} \nis not identical to: foo(arg: "a\r\nb\r\nc\r\n") { \r \n
p1 { \r\n
bar \r\n
} \r\n
} \r\nMaybe its worth experimenting with it...
A lot of snaps contain escaped new line delimiters, currently only |
Why would they need to be modified? Wouldn't we just replace literal CRLFs with LFs in the byte array before hashing?
Some of these would be caused by Certainly not a trivial task. 🙂 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8747 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@N-Olbert Thanks! |
I dont know... If it were just a plain hash, replacing CRLFs with LFs in the byte stream would work, but since we’re using an md5/sha hash of the document / request as a unique identifier (without an explicit equality check) in a lot of cache layers, I think that approach is too simple. F. e. we use the operation / document hash as cache key within the cache middlewares: I think the core keypoints are:
could be treated as the same with either \n or \r\n or any permutation of those after line 1, 2, 3.
So while I see the appeal of the normalization, I don’t think it can be done reliably at the byte level without risking that distinct operations collapse into the same hash - but maybe I oversee something. |
|
There are no literal CRLFs/LFs in a regular GraphQL string, they are escaped. However, block strings would be an issue. Maybe we need a specialized syntax printer that builds a string without whitespace between tokens, and only preserves whitespace inside strings. |
Summary of the changes (Less than 80 chars)
Closes #bugnumber (in this specific format)
Failing tests:
Details
HotChocolate AspNetCore test HotChocolate.AspNetCore.Tests HttpGetSchemaMiddlewareTests Download_GraphQL_Schema Download_GraphQL_Schema(path: "/graphql/schema") Download_GraphQL_Schema(path: "/graphql/schema.graphql") Download_GraphQL_Schema(path: "/graphql/schema/") Download_GraphQL_Schema(path: "/graphql?sdl") Download_GraphQL_Schema_Slicing_Args_Enabled Download_GraphQL_Schema_Slicing_Args_Enabled(path: "/graphql/schema") Download_GraphQL_Schema_Slicing_Args_Enabled(path: "/graphql/schema.graphql") Download_GraphQL_Schema_Slicing_Args_Enabled(path: "/graphql/schema/") Download_GraphQL_Schema_Slicing_Args_Enabled(path: "/graphql?sdl") HttpPostMiddlewareTests SingleRequest_Defer_Results Fusion-vnext test HotChocolate.Fusion.Execution.Tests Execution Serialization JsonOperationPlanSerializationTests Parse_Plan Parse_Plan_With_Node MongoDb test HotChocolate.Types.MongoDb.Tests BsonTypeTests Input_Should_MatchSnapshotAndType_When_Passed Input_Should_MatchSnapshotAndType_When_Passed(fieldName: "double", value: 43,229999999999997, type: typeof(MongoDB.Bson.BsonDouble)) Primitives test HotChocolate.Primitives.Tests NameUtilsTests InvalidName InvalidName(name: "$Bar") InvalidName(name: "1_Bar") InvalidName(name: "1Bar") InvalidName(name: "B+ar") InvalidName(name: "B/ar")