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 some flaky tests #64652

Merged
merged 3 commits into from
Feb 2, 2022
Merged

Commits on Feb 1, 2022

  1. [wasm][debugger] Fix racy test HarnessTests.ExceptionThrown

    The test fails sometimes with:
    
    ```
    [02:40:04] dbug: Inspector-3[0] Failing all waiters because: Runtime.exceptionThrown: {   "timestamp": 1643683204929.399,   "exceptionDetails": {     "exceptionId": 2,     "text": "Uncaught",     "lineNumber": 0,     "columnNumber": 31,     "scriptId": "32",     "stackTrace": {       "callFrames": [         {           "functionName": "",           "scriptId": "32",           "url": "",           "lineNumber": 0,           "columnNumber": 31         }       ]     },     "exception": {       "type": "object",       "subtype": "error",       "className": "ReferenceError",       "description": "ReferenceError: non_existant_fn is not defined\n    at <anonymous>:1:32",       "objectId": "1487416918028189685.1.57",       "preview": {         "type": "object",         "subtype": "error",         "description": "ReferenceError: non_existant_fn is not defined\n    at <anonymous>:1:32",         "overflow": false,         "properties": [           {             "name": "stack",             "type": "string",             "value": "ReferenceError: non_existant_fn is not defined\n    at <anonymous>:1:32"           },           {             "name": "message",             "type": "string",             "value": "non_existant_fn is not defined"           }         ]       }     },     "executionContextId": 1   } }
    
    [02:41:02] dbug: InspectorClient-3[0] Socket is no longer open
    [02:41:02] dbug: InspectorClient-3[0] RunLoop stopped, reason: Cancelled. (parentToken: True, linked: True):
    [02:41:02] dbug: InspectorClient-3[0] Failing 0 pending cmds
    [02:41:02] dbug: InspectorClient-3[0] Loop ended with socket: Aborted
    [02:41:03] dbug: InspectorClient-4[0] connecting to ws://localhost:9400/launch-chrome-and-connect/?test_id=4
    
    [xUnit.net 00:02:07.56]     DebuggerTests.HarnessTests.ExceptionThrown [FAIL]
    [02:41:03] info: Microsoft.WebAssembly.Diagnostics.TestHarnessProxy[0] [testId: 4] New test request for test id 4
      Failed DebuggerTests.HarnessTests.ExceptionThrown [58 s]
      Error Message:
       Assert.Throws() Failure
    Expected: typeof(System.ArgumentException)
    Actual:   typeof(System.Threading.Tasks.TaskCanceledException): Test timed out (elapsed time: 60.0062617)
    ---- System.Threading.Tasks.TaskCanceledException : Test timed out (elapsed time: 60.0062617)
      Stack Trace:
         at DebuggerTests.DebuggerTestBase.SendCommandAndCheck(JObject args, String method, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn, String waitForEvent) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 523
       at DebuggerTests.DebuggerTestBase.EvaluateAndCheck(String expression, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 507
       at DebuggerTests.HarnessTests.<ExceptionThrown>b__1_0() in /_/src/mono/wasm/debugger/DebuggerTestSuite/HarnessTests.cs:line 30
    ----- Inner Stack Trace -----
       at DebuggerTests.DebuggerTestBase.SendCommandAndCheck(JObject args, String method, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn, String waitForEvent) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 523
       at DebuggerTests.DebuggerTestBase.EvaluateAndCheck(String expression, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 507
       at DebuggerTests.HarnessTests.<ExceptionThrown>b__1_0() in /_/src/mono/wasm/debugger/DebuggerTestSuite/HarnessTests.cs:line 30
    ```
    
    The test uses `SendCommand` to evaluate
        `("window.setTimeout(function() { non_existant_fn(); }, 1)`
    which tries to invoke the `non_existant_fn` after 1ms. This causes a
    `Runtime.exceptionThrown` event message to be received, and the
    `Inspector` fails any waiters (eg. `insp.WaitFor(READY)`).
    
    So we have:
    
    1. SendCommand
    2. insp.WaitFor
    
    But the `Runtime.exceptionThrown` can be received before we get to (2),
    thus the waiter from (2) never gets failed, and instead times out.
    radical committed Feb 1, 2022
    Configuration menu
    Copy the full SHA
    ffb16d5 View commit details
    Browse the repository at this point in the history
  2. [wasm][debugger] Remove HarnessTests.BrowserClose

    This is an inherently racy test because we might get the socket closed
    exception first, or the ArgumentException for the cdp events. And
    effectively, it's not a useful test.
    radical committed Feb 1, 2022
    Configuration menu
    Copy the full SHA
    c9cf2ae View commit details
    Browse the repository at this point in the history
  3. [wasm][debugger] Update two array tests

    `ArrayTests.InvalidValueTypeArrayIndex` isn't needed any more because
    array members don't have special ids now.
    
    Fixes dotnet#63560
    radical committed Feb 1, 2022
    Configuration menu
    Copy the full SHA
    eba1515 View commit details
    Browse the repository at this point in the history