Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ public void DefaultTemplate_NoAOT_WithWorkload(string config)
}
}

[Theory]
[InlineData("Debug")]
[InlineData("Release")]
public void DefaultTemplate_BuildAndBuildNative_WithWorkload(string config)
{
string id = $"blz_buildandbuildnative_{config}_{Path.GetRandomFileName()}";

CreateBlazorWasmTemplateProject(id);

BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.Relinked), "/p:WasmBuildNative=true");
}

// Disabling for now - publish folder can have more than one dotnet*hash*js, and not sure
// how to pick which one to check, for the test
//[Theory]
Expand Down
29 changes: 29 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Xunit.Abstractions;
using Xunit.Sdk;
using Microsoft.Playwright;
using System.Runtime.Serialization.Json;
using Microsoft.NET.Sdk.WebAssembly;

#nullable enable

Expand Down Expand Up @@ -834,6 +836,33 @@ protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasm
dotnetJsPath!,
"Expected dotnet.native.js to be same as the runtime pack",
same: dotnetWasmFromRuntimePack);

string bootConfigPath = Path.Combine(binFrameworkDir, "blazor.boot.json");
Assert.True(File.Exists(bootConfigPath), $"Missing '{bootConfigPath}'");

using (var bootConfigContent = File.OpenRead(bootConfigPath))
{
var bootConfig = ParseBootData(bootConfigContent);
foreach (var dotnetJs in bootConfig.resources.runtime.Keys.Where(k => k.StartsWith("dotnet.") && k.EndsWith(".js")))
{
Assert.DoesNotContain(dotnetJs, "..");

string dotnetJsAbsolutePath = Path.Combine(binFrameworkDir, dotnetJs);
Assert.True(File.Exists(dotnetJsPath), $"Missing '{dotnetJsAbsolutePath}'");
}
}
}

private static BootJsonData ParseBootData(Stream stream)
{
stream.Position = 0;
var serializer = new DataContractJsonSerializer(
typeof(BootJsonData),
new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true });

var config = (BootJsonData?)serializer.ReadObject(stream);
Assert.NotNull(config);
return config;
}

protected void AssertBlazorBootJson(string config, bool isPublish, bool isNet7AndBelow, string targetFramework = DefaultTargetFrameworkForBlazor, string? binFrameworkDir=null)
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Playwright" Version="1.21.0" />
<ProjectReference Include="..\..\..\tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj" />
<Compile Include="$(MonoProjectRoot)wasm\debugger\DebuggerTestSuite\BrowserLocator.cs" />

<None Include="$(RepoRoot)\src\mono\wasm\test-main.js" CopyToOutputDirectory="PreserveNewest" />
Expand Down