From a17d3d20b36309257f7a1497bf1d38ad96974247 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:03:34 +0200 Subject: [PATCH] [wasm][debugger] Remove non-deterministic signals from debugger tests. (#77038) * Easy fix. * Non wasm page loading detection. * This is a good test, Sleep was redundant. * This comment can be removed. * Applied radical's idea to simplify the logic. --- .../wasm/debugger/DebuggerTestSuite/BreakpointTests.cs | 2 +- .../debugger/DebuggerTestSuite/DebuggerTestBase.cs | 10 +++++----- .../wasm/debugger/DebuggerTestSuite/ExceptionTests.cs | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 7949ebec263fa..69a99a3fb724b 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -505,7 +505,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain(s expression = "window.setTimeout(function() { " + func_name + "(); }, 1);" }); await cli.SendCommand("Runtime.evaluate", run_method, token); - await Task.Delay(1000, token); + await WaitForEventAsync("Runtime.executionContextCreated"); run_method = JObject.FromObject(new { diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs index 906803936c160..8f7e86d6834f3 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs @@ -1465,17 +1465,17 @@ internal async Task LoadAssemblyAndTestHotReload(string asm_file, strin return await WaitFor(Inspector.PAUSE); } - public async Task WaitForBreakpointResolvedEvent() + public Task WaitForBreakpointResolvedEvent() => WaitForEventAsync("Debugger.breakpointResolved"); + + public async Task WaitForEventAsync(string eventName) { try { - var res = await insp.WaitForEvent("Debugger.breakpointResolved"); - _testOutput.WriteLine ($"breakpoint resolved to {res}"); - return res; + return await insp.WaitForEvent(eventName); } catch (TaskCanceledException) { - throw new XunitException($"Timed out waiting for Debugger.breakpointResolved event"); + throw new XunitException($"Timed out waiting for {eventName} event"); } } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs index a0270c00b4ef6..b4fe302fb66a6 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs @@ -238,7 +238,7 @@ await SendCommand("Page.reload", JObject.FromObject(new { ignoreCache = true })); - Thread.Sleep(1000); + await insp.WaitFor(Inspector.APP_READY); var eval_expr = "window.setTimeout(function() { invoke_static_method (" + $"'{entry_method_name}'" + @@ -278,10 +278,9 @@ public async Task ExceptionTestAllWithReload(string entry_method_name, string cl var pause_location = await SendCommandAndCheck(JObject.FromObject(new { ignoreCache = true - }), "Page.reload",null, 0, 0, null); - Thread.Sleep(1000); + }), "Page.reload", null, 0, 0, null); - // Hit resume to skip + // Hit resume to skip int count = 0; while(true) {