Runtime: System.Diagnostics.TextWriterTraceListenerTests compares month of year only and has bad UTC vs. Localtime logic

Created on 1 Nov 2018  Â·  7Comments  Â·  Source: dotnet/runtime

This bug is in the test case

src/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs

Failing test case (spurious failure):

<failure exception-type="Xunit.Sdk.EqualException">
      <message><![CDATA[Assert.Equal() Failure\n           ↓ (pos 1)\nExpected: 11-DD-YY\nActual:   10-DD-YY\n           ↑ (pos 1)]]></message>
          <stack-trace><![CDATA[   at System.Diagnostics.TextWriterTraceListenerTests.XmlWriterTraceListenerTests.ValidateSystemInfo(XmlDocument document, String eventId, TraceEventType eventType, DateTime date, TraceEventCache eventCache) in /home/joshua/netcore/dotnet/src/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs:line 487
   at System.Diagnostics.TextWriterTraceListenerTests.XmlWriterTraceListenerTests.TraceData_NullDataParams() in /home/joshua/netcore/dotnet/src/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs:line 296]]></stack-trace>
        </failure>

Will fail at the end of the month when UTC has advanced or at the beginning of the month when UTC has not advanced.

Root problem 1) DateTime.Now rather than DateTime.UtcNow
Root problem 2) date.ToString("MM-DD-YY") has the behavior of DD and YY are literals
Root problem 3) Should be a range check to avoid midnight crossing bugs

area-System.Diagnostics.Tracing test bug test-run-core up-for-grabs

Most helpful comment

This was fixed in https://github.com/dotnet/corefx/pull/35692. I didn't know there was an issue open for it. Thanks for the interest, though!

All 7 comments

@joshudson thanks, looks like it failed in official run today also

@joshudson thanks for analysis. Do you want to submit a PR to fix the test?

I'll pass.

In my experience the best date format for non-human processing is yyyy-MM-dd, fyi.

@noahfalk, @tommcdon, @Anipik Sorry for mentioning, do you have any plans on this issue? I'd like to work on it if you're happy about me working on it. 😀

This was fixed in https://github.com/dotnet/corefx/pull/35692. I didn't know there was an issue open for it. Thanks for the interest, though!

Very fortunate that I didn't start working on it without asking. Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iCodeWebApps picture iCodeWebApps  Â·  3Comments

noahfalk picture noahfalk  Â·  3Comments

Timovzl picture Timovzl  Â·  3Comments

chunseoklee picture chunseoklee  Â·  3Comments

yahorsi picture yahorsi  Â·  3Comments