-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[browser] Fix debugger support in WasmAppBuilder #100675
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9c0f879
Fix debugger support in WasmAppBuilder
maraf 17b2452
Fix
maraf b58bcf9
Merge branch 'main' into BrowserDebuggerSupportAppBuilder
maraf 28964d9
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupp…
maraf 4fae095
Abstract test and do a WAB tests
maraf 1080e6c
Fix
maraf 084ca5b
Fix
maraf a577726
Fix + debug
maraf 30e95f0
Fix
maraf dc0b475
Fix
maraf 8983d55
Fix projectId uniqueness
maraf e756304
Use Id for folder name
maraf bfa8463
Fix assert app bundle
maraf aa9e854
FIx passing publishing flag to nested publish
maraf 77fb1d5
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupp…
maraf fe15a5b
Move PublishWithDefaultLevelAndPdbs to WasmSDK only
maraf 8b69df0
Feedback
maraf f58a495
Fix
maraf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
109 changes: 0 additions & 109 deletions
109
src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/DebugLevelTests.cs
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/DebugLevelTestsBase.cs
This file contains hidden or 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,86 @@ | ||
// 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.TestAppScenarios; | ||
|
||
public abstract class DebugLevelTestsBase : AppTestBase | ||
{ | ||
public DebugLevelTestsBase(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
protected void AssertDebugLevel(RunResult result, int value) | ||
{ | ||
Assert.Collection( | ||
result.TestOutput, | ||
m => Assert.Equal($"WasmDebugLevel: {value}", m) | ||
); | ||
} | ||
|
||
protected abstract void SetupProject(string projectId); | ||
protected abstract Task<RunResult> RunForBuild(string configuration); | ||
protected abstract Task<RunResult> RunForPublish(string configuration); | ||
|
||
[Theory] | ||
[InlineData("Debug")] | ||
[InlineData("Release")] | ||
public async Task BuildWithDefaultLevel(string configuration) | ||
{ | ||
SetupProject($"DebugLevelTests_BuildWithDefaultLevel_{configuration}"); | ||
BuildProject(configuration, assertAppBundle: false); | ||
|
||
var result = await RunForBuild(configuration); | ||
AssertDebugLevel(result, -1); | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug", 1)] | ||
[InlineData("Release", 1)] | ||
[InlineData("Debug", 0)] | ||
[InlineData("Release", 0)] | ||
public async Task BuildWithExplicitValue(string configuration, int debugLevel) | ||
{ | ||
SetupProject($"DebugLevelTests_BuildWithExplicitValue_{configuration}"); | ||
BuildProject(configuration, assertAppBundle: false, extraArgs: $"-p:WasmDebugLevel={debugLevel}"); | ||
|
||
var result = await RunForBuild(configuration); | ||
AssertDebugLevel(result, debugLevel); | ||
} | ||
|
||
[Theory] | ||
[InlineData("Debug")] | ||
[InlineData("Release")] | ||
public async Task PublishWithDefaultLevel(string configuration) | ||
{ | ||
SetupProject($"DebugLevelTests_PublishWithDefaultLevel_{configuration}"); | ||
PublishProject(configuration, assertAppBundle: false); | ||
|
||
var result = await RunForPublish(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) | ||
{ | ||
SetupProject($"DebugLevelTests_PublishWithExplicitValue_{configuration}"); | ||
PublishProject(configuration, assertAppBundle: false, extraArgs: $"-p:WasmDebugLevel={debugLevel}"); | ||
|
||
var result = await RunForPublish(configuration); | ||
AssertDebugLevel(result, debugLevel); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/WasmAppBuilderDebugLevelTests.cs
This file contains hidden or 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,70 @@ | ||
// 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.TestAppScenarios; | ||
|
||
public class WasmAppBuilderDebugLevelTests : DebugLevelTestsBase | ||
{ | ||
public WasmAppBuilderDebugLevelTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
protected override void SetupProject(string projectId) | ||
{ | ||
Id = $"{projectId}_{GetRandomId()}"; | ||
string projectfile = CreateWasmTemplateProject(Id, "wasmconsole"); | ||
string projectDir = Path.GetDirectoryName(projectfile)!; | ||
string mainJs = Path.Combine(projectDir, "main.mjs"); | ||
string mainJsContent = File.ReadAllText(mainJs); | ||
mainJsContent = mainJsContent | ||
.Replace("import { dotnet }", "import { dotnet, exit }") | ||
.Replace("await runMainAndExit()", "console.log('TestOutput -> WasmDebugLevel: ' + config.debugLevel); exit(0)"); | ||
File.WriteAllText(mainJs, mainJsContent); | ||
} | ||
|
||
protected override Task<RunResult> RunForBuild(string configuration) | ||
{ | ||
CommandResult res = new RunCommand(s_buildEnv, _testOutput) | ||
.WithWorkingDirectory(_projectDir!) | ||
.ExecuteWithCapturedOutput($"run --no-silent --no-build -c {configuration}"); | ||
|
||
return Task.FromResult(ProcessRunOutput(res)); | ||
} | ||
|
||
private RunResult ProcessRunOutput(CommandResult res) | ||
{ | ||
var output = res.Output.Split(Environment.NewLine); | ||
_testOutput.WriteLine($"DEBUG: parsed lines '{String.Join(", ", output)}'"); | ||
|
||
var prefix = "[] TestOutput -> "; | ||
var testOutput = output | ||
.Where(l => l.StartsWith(prefix)) | ||
.Select(l => l.Substring(prefix.Length)) | ||
.ToArray(); | ||
|
||
_testOutput.WriteLine($"DEBUG: testOutput '{String.Join(", ", testOutput)}'"); | ||
return new RunResult(res.ExitCode, testOutput, output, []); | ||
} | ||
|
||
protected override Task<RunResult> RunForPublish(string configuration) | ||
{ | ||
// WasmAppBuilder does publish to the same folder as build (it overrides the output), | ||
// and thus using dotnet run work correctly for publish as well. | ||
CommandResult res = new RunCommand(s_buildEnv, _testOutput) | ||
.WithWorkingDirectory(_projectDir!) | ||
.ExecuteWithCapturedOutput($"run --no-silent --no-build -c {configuration}"); | ||
|
||
return Task.FromResult(ProcessRunOutput(res)); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/WasmSdkDebugLevelTests.cs
This file contains hidden or 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,46 @@ | ||
// 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.TestAppScenarios; | ||
|
||
public class WasmSdkDebugLevelTests : DebugLevelTestsBase | ||
{ | ||
public WasmSdkDebugLevelTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
protected override void SetupProject(string projectId) => CopyTestAsset("WasmBasicTestApp", projectId, "App"); | ||
|
||
protected override Task<RunResult> RunForBuild(string configuration) => RunSdkStyleAppForBuild(new( | ||
Configuration: configuration, | ||
TestScenario: "DebugLevelTest" | ||
)); | ||
|
||
protected override Task<RunResult> RunForPublish(string configuration) => RunSdkStyleAppForPublish(new( | ||
Configuration: configuration, | ||
TestScenario: "DebugLevelTest" | ||
)); | ||
|
||
[Theory] | ||
[InlineData("Debug")] | ||
[InlineData("Release")] | ||
public async Task PublishWithDefaultLevelAndPdbs(string configuration) | ||
{ | ||
SetupProject($"DebugLevelTests_PublishWithDefaultLevelAndPdbs_{configuration}"); | ||
PublishProject(configuration, assertAppBundle: false, extraArgs: $"-p:CopyOutputSymbolsToPublishDirectory=true"); | ||
|
||
var result = await RunForPublish(configuration); | ||
AssertDebugLevel(result, -1); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.