Repository navigation
Labels
area/mtpMicrosoft.Testing.Platform core library.
Description
Describe the bug
When I run MTP on wasi-wasm runtime, it fails.
Steps To Reproduce
Create wasi-wasm app with .NET 10 Preview 2
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<OutputType>Exe</OutputType>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TUnit" Version="0.19.32" />
</ItemGroup>
</Project>Install wasi workload
dotnet workload install wasi-experimentalBuild it
dotnet buildRun it
cd bin\Debug\net10.0\wasi-wasm\AppBundle
wasmtime run --wasi http --dir . -- dotnet.wasm App1Expected behavior
Runs.
Actual behavior
Unhandled Exception:
System.PlatformNotSupportedException: Arg_PlatformNotSupported
at System.Runtime.InteropServices.PosixSignalRegistration.Register(PosixSignal signal, Action`1 handler)
at System.Runtime.InteropServices.PosixSignalRegistration.Create(PosixSignal signal, Action`1 handler)
at System.Console.add_CancelKeyPress(ConsoleCancelEventHandler value)
at Microsoft.Testing.Platform.Helpers.SystemConsole.add_CancelKeyPress(ConsoleCancelEventHandler value)
at Microsoft.Testing.Platform.Services.CTRLPlusCCancellationTokenSource..ctor(IConsole console, ILogger logger)
at Microsoft.Testing.Platform.Hosts.TestHostBuilder.BuildAsync(ApplicationLoggingState loggingState, TestApplicationOptions testApplicationOptions, IUnhandledExceptionsHandler unhandledExceptionsHandler, DateTimeOffset createBuilderStart)
at Microsoft.Testing.Platform.Builder.TestApplicationBuilder.BuildAsync()
at TestingPlatformEntryPoint.Main(String[] args)
at TestingPlatformEntryPoint.<Main>(String[] args)
Additional context
This particular error would likely go away if WASM was added to this exclusion list:
testfx/src/Platform/Microsoft.Testing.Platform/Services/CTRLPlusCCancellationTokenSource.cs
Lines 24 to 32 in 3564400
| [SupportedOSPlatformGuard("android")] | |
| [SupportedOSPlatformGuard("ios")] | |
| [SupportedOSPlatformGuard("tvos")] | |
| [SupportedOSPlatformGuard("browser")] | |
| private static bool IsCancelKeyPressNotSupported() | |
| => RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")) || | |
| RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")) || | |
| RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")) || | |
| RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); |
Then more places might need fixing similarly. I'm not sure if there is anything else blocking wasm support, would need to get past the first error and see what happens next.
Similar issue: #2196
Reacted by Frulfump
Metadata
Metadata
Assignees
Labels
area/mtpMicrosoft.Testing.Platform core library.
Activity
Youssef1313 commentedon Apr 3, 2025
We were following the same as runtime when annotating the API:
https://github.com/dotnet/runtime/blob/15872212c29cecc8d82da4548c3060f2614665f7/src/libraries/System.Console/src/System/Console.cs#L560-L564
(On our side, we are missing
<SupportedPlatform Include="wasi" />though, but then we still won't get warnings because the annotations on .NET runtime may not be accurate.Youssef1313 commentedon Apr 5, 2025
Jan Jones (@jjonescz) Can you please try with
1.7.0-preview.25204.3from feedhttps://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.jsonand let me know what the next issue (if any) is pleasejjonescz commentedon Apr 5, 2025
Next up is banner:
But I can work around that by passing
--env TESTINGPLATFORM_NOBANNER=1towasmtime.Next up is SHA256:
That's tracked by dotnet/runtime#99126. I don't think it makes sense to add a workaround for this in testfx. So feel free to close this issue. Thanks!
Youssef1313 commentedon Apr 5, 2025
That won't be sufficient as
ConsoleLogwill be called in other code paths later that are not controllable via env variables. But generally I think we will need proper API annotations from .NET runtime so we get analyzer warnings instead of chasing things one-by-one this way.For SHA256, this code path is for telemetry, which we can completely skip automatically when we know the API is not supported. Or you can also opt-out by setting
TESTINGPLATFORM_TELEMETRY_OPTOUTenvironment variable to 1. But I'm expecting you will get toBrowserOutputDevice.ConsoleLogagain.I'm also not sure what differences are between wasi and browser. In BrowserOutputDevice we simply try to call
console.logbut looks like this doesn't work in wasi. Then I'm not sure if our regularTerminalOutputDevicewill work or not, and what's the current threading support status for wasi. To my last knowledge for browser, it's an opt-in feature? I expect wasi to probably be the same?Larry Ewing (@lewing) Is wasi expected to still be experimental when .NET 10 is GA?
jjonescz commentedon Apr 5, 2025
Yes, that's mentioned in dotnet/runtime#99126 (comment) - there are no annotations yet since wasi-wasm is experimental.
Thanks, fwiw, after that I get to this point:
As you say, that's probably because threading is not supported.
Youssef1313 commentedon Apr 5, 2025
Hmm, I'm interpreting the last one for
Task.InternalWaitas any asyncMainentry point that doesn't completely synchronously isn't going to work. e.g, a simpleawait Task.Delay(...)in async Main won't work. I'll need to discuss more with runtime team to better understand the current situation, what's supported and what is not, and when more support is expected to happen.Youssef1313 commentedon Jan 9, 2026
Re-opening as it's not fixed. Async in Main still causes trouble.
Make samples/WasiPlayground actually publish and boot MTP on wasi-wasm
Address review comments and fix CA1416 on wasi target
Evangelink commentedon Jul 16, 2026
Closing this as resolved. Running MSTest and Microsoft.Testing.Platform on wasm is now supported and merged to
main, with end-to-end acceptance coverage that publishes forwasi-wasmand runs underwasmtime(plus browser-wasm coverage):Main/ threading (the reason this was reopened): single-threaded wasm has no thread pool, soTask.Runcontinuations never run and blocking waits throwPlatformNotSupportedException. The platform and adapter now detect this viaRuntimeFeatureHelper.IsMultiThreaded/RuntimeContext.IsMultiThreadedand fall back to inline/synchronous execution on the thread-dependent spots (message-bus consumers, shutdown watchdog, telemetry ingest, countdown-event wait, adapter per-test task factory). A user-authoredasync Task Mainworks.ConsoleLog: dedicatedWasiOutputDevice/BrowserOutputDevicereplace theJSMarshalerType-based path.dotnet/runtime#99126): telemetry is skipped on wasm instead of hashing.Coverage lives in
Microsoft.Testing.Platform.Acceptance.IntegrationTests.WasmExecutionTests(raw platform),MSTest.Acceptance.IntegrationTests.WasmExecutionTests(MSTest adapter), andBrowserWasmExecutionTests(browser).Some extension-level limitations remain and are tracked separately (e.g. hang-dump relies on
System.Diagnostics.Process#8557, and the Azure DevOps provider'sHttpClientusesAutomaticDecompression), but the core "allow running on wasm" ask is done. General execution work is tracked under #2196.