Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ jobs:
platform: x64
- name: Set up zlib-static
run: sudo apt-get install -y libkrb5-dev
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Set up v8
run: npm install jsvu -g && jsvu --os=linux64 --engines=v8 && echo "$HOME/.jsvu/bin" >> $GITHUB_PATH
- name: Install wasm-tools workload
run: ./build.cmd install-wasm-tools
- name: Run task 'build'
run: ./build.cmd build
- name: Run task 'unit-tests'
Expand All @@ -79,6 +87,14 @@ jobs:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Set up v8
run: npm install jsvu -g && jsvu --os=mac64 --engines=v8 && echo "$HOME/.jsvu/bin" >> $GITHUB_PATH
- name: Install wasm-tools workload
run: ./build.cmd install-wasm-tools
- name: Run task 'build'
run: ./build.cmd build
- name: Run task 'unit-tests'
Expand Down
20 changes: 20 additions & 0 deletions build/BenchmarkDotNet.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ public HelpInfo GetHelp()
}
}

[TaskName(Name)]
[TaskDescription("Install wasm-tools workload")]
public class InstallWasmToolsWorkload : FrostingTask<BuildContext>, IHelpProvider
{
private const string Name = "install-wasm-tools";

public override void Run(BuildContext context) => context.BuildRunner.InstallWorkload("wasm-tools");

public HelpInfo GetHelp()
{
return new HelpInfo
{
Examples = new[]
{
new Example(Name)
}
};
}
}

[TaskName(Name)]
[TaskDescription("Run unit tests (fast)")]
[IsDependentOn(typeof(BuildTask))]
Expand Down
11 changes: 11 additions & 0 deletions build/BenchmarkDotNet.Build/Runners/BuildRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Cake.Common.Tools.DotNet.Build;
using Cake.Common.Tools.DotNet.Pack;
using Cake.Common.Tools.DotNet.Restore;
using Cake.Common.Tools.DotNet.Workload.Install;
using Cake.Core;
using Cake.Core.IO;

Expand All @@ -28,6 +29,16 @@ public void Restore()
});
}

public void InstallWorkload(string workloadId)
{
context.DotNetWorkloadInstall(workloadId,
new DotNetWorkloadInstallSettings
{
IncludePreviews = true,
NoCache = true
});
}

public void Build()
{
context.Information("BuildSystemProvider: " + context.BuildSystem().Provider);
Expand Down
9 changes: 9 additions & 0 deletions tests/BenchmarkDotNet.IntegrationTests/AppBundle/test-main.js
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()
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="AppBundle\**" CopyToOutputDirectory="Always" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
Expand Down
51 changes: 51 additions & 0 deletions tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs
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");
}
}
}
}
}