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
22 changes: 12 additions & 10 deletions src/mono/wasm/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public BlazorWasmBuildPublishTests(ITestOutputHelper output, SharedBuildPerTestC
[InlineData("Release")]
public void DefaultTemplate_WithoutWorkload(string config)
{
string id = $"blz_no_workload_{config}";
string id = $"blz_no_workload_{config}_{Path.GetRandomFileName()}";
CreateBlazorWasmTemplateProject(id);

// Build
Expand All @@ -43,7 +43,7 @@ public void DefaultTemplate_WithoutWorkload(string config)
[InlineData("Release")]
public void DefaultTemplate_NoAOT_WithWorkload(string config)
{
string id = $"blz_no_aot_{config}";
string id = $"blz_no_aot_{config}_{Path.GetRandomFileName()}";
CreateBlazorWasmTemplateProject(id);

BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.FromRuntimePack));
Expand All @@ -63,7 +63,7 @@ public void DefaultTemplate_NoAOT_WithWorkload(string config)
[InlineData("Release")]
public void DefaultTemplate_AOT_InProjectFile(string config)
{
string id = $"blz_aot_prj_file_{config}";
string id = $"blz_aot_prj_file_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateBlazorWasmTemplateProject(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "<RunAOTCompilation>true</RunAOTCompilation>");

Expand All @@ -82,10 +82,10 @@ public void DefaultTemplate_AOT_InProjectFile(string config)
[InlineData("Debug", false)]
[InlineData("Release", true)]
[InlineData("Release", false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRelink)
{
string id = $"blz_deploy_on_build_{config}_{nativeRelink}";
string id = $"blz_deploy_on_build_{config}_{nativeRelink}_{Path.GetRandomFileName()}";
string projectFile = CreateProjectWithNativeReference(id);
AddItemsPropertiesToProject(projectFile, extraProperties: nativeRelink ? string.Empty : "<RunAOTCompilation>true</RunAOTCompilation>");

Expand All @@ -94,7 +94,7 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel

var expectedFileType = nativeRelink ? NativeFilesType.Relinked : NativeFilesType.AOT;

AssertDotNetNativeFiles(expectedFileType, config, forPublish: true);
AssertDotNetNativeFiles(expectedFileType, config, forPublish: true, targetFramework: DefaultTargetFrameworkForBlazor);
AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: false);

if (expectedFileType == NativeFilesType.AOT)
Expand Down Expand Up @@ -147,7 +147,7 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel
[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
public void WithNativeReference_AOTInProjectFile(string config)
{
string id = $"blz_nativeref_aot_{config}";
string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateProjectWithNativeReference(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "<RunAOTCompilation>true</RunAOTCompilation>");

Expand All @@ -165,7 +165,7 @@ public void WithNativeReference_AOTInProjectFile(string config)
[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
public void WithNativeReference_AOTOnCommandLine(string config)
{
string id = $"blz_nativeref_aot_{config}";
string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
CreateProjectWithNativeReference(id);

BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.Relinked));
Expand All @@ -182,7 +182,7 @@ public void WithNativeReference_AOTOnCommandLine(string config)
public void WithDllImportInMainAssembly(string config)
{
// Based on https://github.com/dotnet/runtime/issues/59255
string id = $"blz_dllimp_{config}";
string id = $"blz_dllimp_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateProjectWithNativeReference(id);
string nativeSource = @"
#include <stdio.h>
Expand Down Expand Up @@ -233,14 +233,15 @@ void CheckNativeFileLinked(bool forPublish)
[Fact]
public void BugRegression_60479_WithRazorClassLib()
{
string id = "blz_razor_lib_top";
string id = $"blz_razor_lib_top_{Path.GetRandomFileName()}";
InitBlazorWasmProjectDir(id);

string wasmProjectDir = Path.Combine(_projectDir!, "wasm");
string wasmProjectFile = Path.Combine(wasmProjectDir, "wasm.csproj");
Directory.CreateDirectory(wasmProjectDir);
new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false)
.WithWorkingDirectory(wasmProjectDir)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("new blazorwasm")
.EnsureSuccessful();

Expand All @@ -249,6 +250,7 @@ public void BugRegression_60479_WithRazorClassLib()
Directory.CreateDirectory(razorProjectDir);
new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false)
.WithWorkingDirectory(razorProjectDir)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("new razorclasslib")
.EnsureSuccessful();

Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/BlazorWasmTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private CommandResult PublishForRequiresWorkloadTest(string config, string extra
string publishLogPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}.binlog");
return new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("publish",
$"-bl:{publishLogPath}",
$"-p:Configuration={config}");
Expand Down Expand Up @@ -109,6 +110,7 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string
string publishLogPath = Path.Combine(logPath, $"{id}.binlog");
CommandResult result = new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("publish",
$"-bl:{publishLogPath}",
(aot ? "-p:RunAOTCompilation=true" : ""),
Expand Down
6 changes: 1 addition & 5 deletions src/mono/wasm/Wasm.Build.Tests/BuildEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BuildEnvironment
public static readonly string RelativeTestAssetsPath = @"..\testassets\";
public static readonly string TestAssetsPath = Path.Combine(AppContext.BaseDirectory, "testassets");
public static readonly string TestDataPath = Path.Combine(AppContext.BaseDirectory, "data");
public static readonly string TmpPath = Path.Combine(Path.GetTempPath(), "wasmbuildtests");
public static readonly string TmpPath = Path.Combine(AppContext.BaseDirectory, "wbt");

private static readonly Dictionary<string, string> s_runtimePackVersions = new();

Expand Down Expand Up @@ -107,7 +107,6 @@ public BuildEnvironment()
EnvVars["DOTNET_INSTALL_DIR"] = sdkForWorkloadPath;
EnvVars["DOTNET_MULTILEVEL_LOOKUP"] = "0";
EnvVars["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "1";
EnvVars["MSBuildSDKsPath"] = string.Empty;
EnvVars["PATH"] = $"{sdkForWorkloadPath}{Path.PathSeparator}{Environment.GetEnvironmentVariable("PATH")}";
EnvVars["EM_WORKAROUND_PYTHON_BUG_34780"] = "1";

Expand Down Expand Up @@ -160,8 +159,5 @@ public string GetRuntimeNativeDir(string tfm = BuildTestBase.DefaultTargetFramew

protected static string s_directoryBuildPropsForLocal = File.ReadAllText(Path.Combine(TestDataPath, "Local.Directory.Build.props"));
protected static string s_directoryBuildTargetsForLocal = File.ReadAllText(Path.Combine(TestDataPath, "Local.Directory.Build.targets"));

protected static string s_directoryBuildPropsForBlazorLocal = File.ReadAllText(Path.Combine(TestDataPath, "Blazor.Local.Directory.Build.props"));
protected static string s_directoryBuildTargetsForBlazorLocal = File.ReadAllText(Path.Combine(TestDataPath, "Blazor.Local.Directory.Build.targets"));
}
}
Loading