Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][debugger] Fix tests broken on 'main' #68054

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ internal async Task CheckCustomType(JToken actual_val, JToken exp_val, string la
}
}

internal async Task CheckProps(JToken actual, object exp_o, string label, int num_fields = -1)
internal async Task CheckProps(JToken actual, object exp_o, string label, int num_fields = -1, bool skip_num_fields_check = false)
{
if (exp_o.GetType().IsArray || exp_o is JArray)
{
Expand Down Expand Up @@ -738,8 +738,11 @@ internal async Task CheckProps(JToken actual, object exp_o, string label, int nu
if (exp == null)
exp = JObject.FromObject(exp_o);

num_fields = num_fields < 0 ? exp.Values<JToken>().Count() : num_fields;
Assert.True(num_fields == actual.Count(), $"[{label}] Number of fields don't match, Expected: {num_fields}, Actual: {actual.Count()}");
if (!skip_num_fields_check)
{
num_fields = num_fields < 0 ? exp.Values<JToken>().Count() : num_fields;
Assert.True(num_fields == actual.Count(), $"[{label}] Number of fields don't match, Expected: {num_fields}, Actual: {actual.Count()}");
}

foreach (var kvp in exp)
{
Expand Down Expand Up @@ -832,15 +835,15 @@ internal async Task<JToken> GetObjectOnFrame(JToken frame, string name)
}

// Find an object with @name, *fetch* the object, and check against @o
internal async Task<JToken> CompareObjectPropertiesFor(JToken locals, string name, object o, string label = null, int num_fields = -1)
internal async Task<JToken> CompareObjectPropertiesFor(JToken locals, string name, object o, string label = null, int num_fields = -1, bool skip_num_fields_check = false)
{
if (label == null)
label = name;
var props = await GetObjectOnLocals(locals, name);
try
{
if (o != null)
await CheckProps(props, o, label, num_fields);
await CheckProps(props, o, label, num_fields, skip_num_fields_check);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could reflect in the test ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, and it's a little messy. And the number of members being returned will also change soon (to include private ones), so I'll have to stick with this check!

return props;
}
catch
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ await CompareObjectPropertiesFor(frame_locals, "ts",
Days = TNumber(3530),
Minutes = TNumber(2),
Seconds = TNumber(4),
}, "ts_props", num_fields: 12);
}, "ts_props", skip_num_fields_check: true);

// DateTimeOffset
await CompareObjectPropertiesFor(frame_locals, "dto",
Expand All @@ -572,7 +572,7 @@ await CompareObjectPropertiesFor(frame_locals, "dto",
Day = TNumber(2),
Year = TNumber(2020),
DayOfWeek = TEnum("System.DayOfWeek", "Thursday")
}, "dto_props", num_fields: 20);
}, "dto_props", skip_num_fields_check: true);

var DT = new DateTime(2004, 10, 15, 1, 2, 3);
var DTO = new DateTimeOffset(dt0, new TimeSpan(2, 14, 0));
Expand Down