-
-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Integration Test for WASM (#2532)
* Write failing wasm test * Use local dotnet installation to install workload * Add v8 to path * Add wasm-tools workload installation to build project, thanks @ilonatommy --------- Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com> Co-authored-by: Tim Cassell <35501420+timcassell@users.noreply.github.com>
- Loading branch information
1 parent
f17d40e
commit 4435799
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/BenchmarkDotNet.IntegrationTests/AppBundle/test-main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
import { dotnet } from './_framework/dotnet.js' | ||
|
||
await dotnet | ||
.withDiagnosticTracing(false) | ||
.withApplicationArguments(...arguments) | ||
.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.IO; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Environments; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Portability; | ||
using BenchmarkDotNet.Tests.Loggers; | ||
using BenchmarkDotNet.Tests.XUnit; | ||
using BenchmarkDotNet.Toolchains.DotNetCli; | ||
using BenchmarkDotNet.Toolchains.MonoWasm; | ||
using Xunit.Abstractions; | ||
|
||
namespace BenchmarkDotNet.IntegrationTests | ||
{ | ||
public class WasmTests : BenchmarkTestExecutor | ||
{ | ||
public WasmTests(ITestOutputHelper output) : base(output) { } | ||
|
||
[FactEnvSpecific("WASM is only supported on Unix", EnvRequirement.NonWindows)] | ||
public void WasmIsSupported() | ||
{ | ||
var dotnetVersion = "net8.0"; | ||
var logger = new OutputLogger(Output); | ||
var netCoreAppSettings = new NetCoreAppSettings(dotnetVersion, null, "Wasm"); | ||
var mainJsPath = Path.Combine(AppContext.BaseDirectory, "AppBundle", "test-main.js"); | ||
|
||
var config = ManualConfig.CreateEmpty() | ||
.AddLogger(logger) | ||
.AddJob(Job.Dry | ||
.WithArguments([new MsBuildArgument($"/p:WasmMainJSPath={mainJsPath}")]) | ||
.WithRuntime(new WasmRuntime(dotnetVersion, moniker: RuntimeMoniker.WasmNet80, javaScriptEngineArguments: "--expose_wasm --module")) | ||
.WithToolchain(WasmToolchain.From(netCoreAppSettings))) | ||
.WithOption(ConfigOptions.GenerateMSBuildBinLog, true); | ||
|
||
CanExecute<WasmBenchmark>(config); | ||
} | ||
|
||
public class WasmBenchmark | ||
{ | ||
[Benchmark] | ||
public void Check() | ||
{ | ||
if (!RuntimeInformation.IsWasm) | ||
{ | ||
throw new Exception("Incorrect runtime detection"); | ||
} | ||
} | ||
} | ||
} | ||
} |