Skip to content

Commit 895715e

Browse files
authored
[wasm][debugger] Fix tests broken on 'main' (#68054)
This test broke because it was checking for the number of members on `System.TimeSpan`, and that changed with #67666 , which added new members like `TotalNanoseconds`. The test shouldn't depend on this number anyway, so remove that. ``` Failed DebuggerTests.MiscTests.InspectLocalsForToStringDescriptions(line: 137, col: 12, method_name: "MethodWithLocalsForToStringTest", call_other: False, invoke_async: False) [758 ms] Error Message: [ts_props] Number of fields don't match, Expected: 12, Actual: 16 Expected: True Actual: False Stack Trace: at DebuggerTests.DebuggerTestBase.CheckProps(JToken actual, Object exp_o, String label, Int32 num_fields) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 800 at DebuggerTests.DebuggerTestBase.CompareObjectPropertiesFor(JToken locals, String name, Object o, String label, Int32 num_fields) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 908 at DebuggerTests.MiscTests.InspectLocalsForToStringDescriptions(Int32 line, Int32 col, String method_name, Boolean call_other, Boolean invoke_async) in /_/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs:line 559 ```
1 parent 300616e commit 895715e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ internal async Task CheckCustomType(JToken actual_val, JToken exp_val, string la
709709
}
710710
}
711711

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

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

744747
foreach (var kvp in exp)
745748
{
@@ -832,15 +835,15 @@ internal async Task<JToken> GetObjectOnFrame(JToken frame, string name)
832835
}
833836

834837
// Find an object with @name, *fetch* the object, and check against @o
835-
internal async Task<JToken> CompareObjectPropertiesFor(JToken locals, string name, object o, string label = null, int num_fields = -1)
838+
internal async Task<JToken> CompareObjectPropertiesFor(JToken locals, string name, object o, string label = null, int num_fields = -1, bool skip_num_fields_check = false)
836839
{
837840
if (label == null)
838841
label = name;
839842
var props = await GetObjectOnLocals(locals, name);
840843
try
841844
{
842845
if (o != null)
843-
await CheckProps(props, o, label, num_fields);
846+
await CheckProps(props, o, label, num_fields, skip_num_fields_check);
844847
return props;
845848
}
846849
catch

src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ await CompareObjectPropertiesFor(frame_locals, "ts",
563563
Days = TNumber(3530),
564564
Minutes = TNumber(2),
565565
Seconds = TNumber(4),
566-
}, "ts_props", num_fields: 12);
566+
}, "ts_props", skip_num_fields_check: true);
567567

568568
// DateTimeOffset
569569
await CompareObjectPropertiesFor(frame_locals, "dto",
@@ -572,7 +572,7 @@ await CompareObjectPropertiesFor(frame_locals, "dto",
572572
Day = TNumber(2),
573573
Year = TNumber(2020),
574574
DayOfWeek = TEnum("System.DayOfWeek", "Thursday")
575-
}, "dto_props", num_fields: 20);
575+
}, "dto_props", skip_num_fields_check: true);
576576

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

0 commit comments

Comments
 (0)