From 80dbd6929c00bf4d97dba93f7fb3efe2672951d5 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan <96171496+mkhamoyan@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:22:25 +0200 Subject: [PATCH] [browser][wbt] Fix `InvalidOperationException: There is no currently active test` (#105561) * Unsubscribe from event handlers * Fix wasi default scenario --- .../extra-platforms/runtime-extra-platforms-wasm.yml | 2 +- src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml index 056d070705a01..ea18dd02459c9 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml @@ -185,7 +185,7 @@ jobs: shouldContinueOnError: ${{ not(parameters.isWasmOnlyBuild) }} alwaysRun: ${{ variables.isRollingBuild }} scenarios: - - WasmTestOnV8 + - WasmTestOnWasmtime # Hybrid Globalization tests - template: /eng/pipelines/common/templates/wasm-library-tests.yml diff --git a/src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs b/src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs index eb2b80302b116..c8289da17350d 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs @@ -107,7 +107,7 @@ private async Task ExecuteAsyncInternal(string executable, string { var output = new List(); CurrentProcess = CreateProcess(executable, args); - CurrentProcess.ErrorDataReceived += (s, e) => + DataReceivedEventHandler errorHandler = (s, e) => { if (e.Data == null) return; @@ -118,7 +118,7 @@ private async Task ExecuteAsyncInternal(string executable, string ErrorDataReceived?.Invoke(s, e); }; - CurrentProcess.OutputDataReceived += (s, e) => + DataReceivedEventHandler outputHandler = (s, e) => { if (e.Data == null) return; @@ -129,11 +129,17 @@ private async Task ExecuteAsyncInternal(string executable, string OutputDataReceived?.Invoke(s, e); }; + CurrentProcess.ErrorDataReceived += errorHandler; + CurrentProcess.OutputDataReceived += outputHandler; + var completionTask = CurrentProcess.StartAndWaitForExitAsync(); CurrentProcess.BeginOutputReadLine(); CurrentProcess.BeginErrorReadLine(); await completionTask; + CurrentProcess.ErrorDataReceived -= errorHandler; + CurrentProcess.OutputDataReceived -= outputHandler; + RemoveNullTerminator(output); return new CommandResult(