Skip to content

Commit

Permalink
[wasm] System.Data.Tests - add debug info, to help with the test fail…
Browse files Browse the repository at this point in the history
…ure (#56838)

`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: #47968
  • Loading branch information
radical committed Aug 5, 2021
1 parent 42066d6 commit f11c8ff
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 f11c8ff

Please sign in to comment.