Skip to content

Commit

Permalink
[browser][wbt] Fix `InvalidOperationException: There is no currently …
Browse files Browse the repository at this point in the history
…active test` (dotnet#105561)

* Unsubscribe from event handlers
* Fix wasi default scenario
  • Loading branch information
mkhamoyan committed Jul 31, 2024
1 parent fd2b245 commit 80dbd69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private async Task<CommandResult> ExecuteAsyncInternal(string executable, string
{
var output = new List<string>();
CurrentProcess = CreateProcess(executable, args);
CurrentProcess.ErrorDataReceived += (s, e) =>
DataReceivedEventHandler errorHandler = (s, e) =>
{
if (e.Data == null)
return;
Expand All @@ -118,7 +118,7 @@ private async Task<CommandResult> ExecuteAsyncInternal(string executable, string
ErrorDataReceived?.Invoke(s, e);
};

CurrentProcess.OutputDataReceived += (s, e) =>
DataReceivedEventHandler outputHandler = (s, e) =>
{
if (e.Data == null)
return;
Expand All @@ -129,11 +129,17 @@ private async Task<CommandResult> 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(
Expand Down

0 comments on commit 80dbd69

Please sign in to comment.