Skip to content

Commit

Permalink
[wasm] System.Data.Tests - add debug info, to help with the failure
Browse files Browse the repository at this point in the history
`System.Data.Tests.AppDomainsAndFormatInfo.Bug55978` fails sometimes for
wasm:

```
Assert.Equal() Failure
Expected: 2
Actual:   3

Stack trace
   at System.Data.Tests.AppDomainsAndFormatInfo.Bug55978()
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
```

To debug the issue, this dumps some state when the test fails.

Issue: dotnet#47968
  • Loading branch information
radical committed Aug 4, 2021
1 parent 9514716 commit 00dc3a5
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters.Tests;
using System.Tests;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using Microsoft.DotNet.RemoteExecutor;
Expand Down Expand Up @@ -3586,7 +3587,22 @@ public void Bug55978()
DateTime.Now.AddDays(2),
DateTime.Now.AddDays(4));
Assert.Equal(10, dt.Rows.Count);
Assert.Equal(2, dv.Count);

int expectedRowCount = 2;
if (dv.Count != expectedRowCount)
{
StringBuilder sb = new();
sb.AppendLine($"DataView.Rows.Count: Expected: {expectedRowCount}, Actual: {dv.Count}. Debug data: RowFilter: {dv.RowFilter}, date: {date}");
for (int i = 0; i < dv.Count; i++)
{
sb.Append($"row#{i}: ");
foreach (var row in dv[i].Row.ItemArray)
sb.Append($"'{row}', ");
sb.AppendLine();
}

Assert.True(expectedRowCount == dv.Count, sb.ToString());
}
}

[Fact]
Expand Down

0 comments on commit 00dc3a5

Please sign in to comment.