-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wasm] Stop testing with V8 and wasmconsole
#108711
Changes from 14 commits
a4d9018
5412473
f3a3c43
c08ef19
5842b3b
fc13b3e
381a362
098d270
1842e1f
bce55b3
8267426
860a1e3
ab008f8
5b40168
66897a5
47bfe38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Wasm.Build.Tests.TestAppScenarios; | ||
|
||
#nullable enable | ||
|
||
namespace Wasm.Build.Tests.Blazor; | ||
|
||
public class DebugLevelTests : AppTestBase | ||
{ | ||
public DebugLevelTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should merge this one with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was not done because it would require more refactoring. In the feedback commit I moved them to one file and made them use |
||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug")] | ||
[InlineData("Release")] | ||
public async Task PublishWithDefaultLevelAndPdbs(string configuration) | ||
{ | ||
CopyTestAsset("WasmBasicTestApp", $"DebugLevelTests_PublishWithDefaultLevelAndPdbs_{configuration}", "App"); | ||
PublishProject(configuration, assertAppBundle: false, extraArgs: $"-p:CopyOutputSymbolsToPublishDirectory=true"); | ||
|
||
var result = await RunSdkStyleAppForBuild(new( | ||
Configuration: configuration, | ||
TestScenario: "DebugLevelTest" | ||
)); | ||
Assert.Contains($"WasmDebugLevel: -1", result.TestOutput); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
#nullable enable | ||
|
||
namespace Wasm.Build.Tests; | ||
|
||
public class DebugLevelTests : WasmTemplateTestsBase | ||
{ | ||
public DebugLevelTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
private string SetupBrowserProject(string projectId, string extraProperties = "") | ||
{ | ||
string id = $"{projectId}_{GetRandomId()}"; | ||
string projectfile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: extraProperties); | ||
|
||
UpdateBrowserMainJs(); | ||
string mainJs = Path.Combine("wwwroot", "main.js"); | ||
UpdateFile(mainJs, new Dictionary<string, string> | ||
{ | ||
{ "import { dotnet }", "import { dotnet, exit }" }, | ||
{"await dotnet.run()", "console.log('TestOutput -> WasmDebugLevel: ' + config.debugLevel); exit(42)" } | ||
}); | ||
return projectfile; | ||
} | ||
|
||
private void AssertDebugLevel(string result, int value) | ||
=> Assert.Contains($"WasmDebugLevel: {value}", result); | ||
|
||
private BuildProjectOptions GetProjectOptions(bool isPublish = false) => | ||
new BuildProjectOptions( | ||
DotnetWasmFromRuntimePack: !isPublish, | ||
CreateProject: false, | ||
HasV8Script: false, | ||
MainJS: "main.js", | ||
Publish: isPublish, | ||
AssertAppBundle: false | ||
); | ||
|
||
private string BuildPublishProject(string projectFile, string config, bool isPublish = false) | ||
{ | ||
string projectName = Path.GetFileNameWithoutExtension(projectFile); | ||
var buildArgs = new BuildArgs(projectName, config, false, projectName, null); | ||
buildArgs = ExpandBuildArgs(buildArgs); | ||
(string _, string output) = BuildTemplateProject(buildArgs, | ||
buildArgs.Id, | ||
GetProjectOptions(isPublish) | ||
); | ||
return output; | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug")] | ||
[InlineData("Release")] | ||
public async Task BuildWithDefaultLevel(string configuration) | ||
{ | ||
string projectFile = SetupBrowserProject($"DebugLevelTests_BuildWithDefaultLevel_{configuration}"); | ||
BuildPublishProject(projectFile, configuration); | ||
|
||
string result = await RunBuiltBrowserApp(configuration, projectFile); | ||
AssertDebugLevel(result, -1); | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug", 1)] | ||
[InlineData("Release", 1)] | ||
[InlineData("Debug", 0)] | ||
[InlineData("Release", 0)] | ||
public async Task BuildWithExplicitValue(string configuration, int debugLevel) | ||
{ | ||
string debugLvlProp = $"<WasmDebugLevel>{debugLevel}</WasmDebugLevel>"; | ||
string projectFile = SetupBrowserProject($"DebugLevelTests_BuildWithExplicitValue_{configuration}", extraProperties: debugLvlProp); | ||
BuildPublishProject(projectFile, configuration); | ||
|
||
string result = await RunBuiltBrowserApp(configuration, projectFile); | ||
AssertDebugLevel(result, debugLevel); | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug")] | ||
[InlineData("Release")] | ||
public async Task PublishWithDefaultLevel(string configuration) | ||
{ | ||
string projectFile = SetupBrowserProject($"DebugLevelTests_PublishWithDefaultLevel_{configuration}"); | ||
BuildPublishProject(projectFile, configuration, isPublish: true); | ||
|
||
string result = await RunPublishedBrowserApp(configuration); | ||
AssertDebugLevel(result, 0); | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug", 1)] | ||
[InlineData("Release", 1)] | ||
[InlineData("Debug", -1)] | ||
[InlineData("Release", -1)] | ||
public async Task PublishWithExplicitValue(string configuration, int debugLevel) | ||
{ | ||
string debugLvlProp = $"<WasmDebugLevel>{debugLevel}</WasmDebugLevel>"; | ||
string projectFile = SetupBrowserProject($"DebugLevelTests_PublishWithExplicitValue_{configuration}", debugLvlProp); | ||
BuildPublishProject(projectFile, configuration, isPublish: true); | ||
|
||
string result = await RunBuiltBrowserApp(configuration, projectFile); | ||
AssertDebugLevel(result, debugLevel); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to override it here? Blazor and Wasm SDK should behave the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, originally I didn't notice they are the same, it can be left in
WasmSdkBasedProjectProvider
only.Note for the future: once we will align
BlazorBuildOptions
andAssertWasmSdkBundleOptions
then maybe we will even use WASM SDK provider in Blazor and dropBlazorWasmProjectProvider
.