Skip to content
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][debugger] Fix source-link test #62786

Merged
merged 3 commits into from
Dec 15, 2021
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
4 changes: 2 additions & 2 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,14 @@ internal void AddMethod(MethodInfo mi)
return (start.StartLocation.Line, start.StartLocation.Column, end.EndLocation.Line, end.EndLocation.Column);
}

private async Task<MemoryStream> GetDataAsync(Uri uri, CancellationToken token)
private static async Task<MemoryStream> GetDataAsync(Uri uri, CancellationToken token)
{
var mem = new MemoryStream();
try
{
if (uri.IsFile && File.Exists(uri.LocalPath))
{
using (FileStream file = File.Open(SourceUri.LocalPath, FileMode.Open))
using (FileStream file = File.Open(uri.LocalPath, FileMode.Open))
radical marked this conversation as resolved.
Show resolved Hide resolved
{
await file.CopyToAsync(mem, token).ConfigureAwait(false);
mem.Position = 0;
Expand Down
29 changes: 29 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,38 @@ await LoadAssemblyDynamically(
Assert.DoesNotContain(source_location, scripts.Values);
}

[Fact]
public async Task GetSourceUsingSourceUri()
{
//testing without using sourcelink, expected values at GetSourceAsync
//SourceUri - file:///LOCAL_PATH/runtime/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
//SourceLinkUri - empty
var bp1_res = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8);

Assert.EndsWith("debugger-test.cs", bp1_res.Value["breakpointId"].ToString());
Assert.Equal(1, bp1_res.Value["locations"]?.Value<JArray>()?.Count);

var loc = bp1_res.Value["locations"]?.Value<JArray>()[0];

var sourceToGet = JObject.FromObject(new
{
scriptId = loc["scriptId"]?.Value<string>()
});

Assert.Equal("dotnet://debugger-test.dll/debugger-test.cs", scripts[loc["scriptId"]?.Value<string>()]);
var source = await cli.SendCommand("Debugger.getScriptSource", sourceToGet, token);
Assert.True(source.IsOk);
}
[Fact]
public async Task GetSourceUsingSourceLink()
{
//testing using sourcelink, expected values at GetSourceAsync
// On CI
//SourceUri - file:///fakepath/LOCAL_PATH/runtime/src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
//SourceLinkUri - file:///LOCAL_PATH/runtime/src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
// Locally
// SourceUri - file:////src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
// SourceLinkUri - https://raw.githubusercontent.com/FORK/runtime/COMMIT_ID/src/mono/wasm/debugger/tests/debugger-test-with-source-link/test.cs
var bp = await SetBreakpointInMethod("debugger-test-with-source-link.dll", "DebuggerTests.ClassToBreak", "TestBreakpoint", 0);
var pause_location = await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method ('[debugger-test-with-source-link] DebuggerTests.ClassToBreak:TestBreakpoint'); }, 1);",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>LibraryTest</PackageId>
<Version>1.0.0</Version>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/dotnet/runtime.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<EnableSourceLink>true</EnableSourceLink>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<IncludeSymbols>true</IncludeSymbols>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
<DisableSourceLink>false</DisableSourceLink>
</PropertyGroup>
<PropertyGroup>
<PackageId>LibraryTest</PackageId>
<Version>1.0.0</Version>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
</PropertyGroup>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/dotnet/runtime.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<EnableSourceLink>true</EnableSourceLink>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<IncludeSymbols>true</IncludeSymbols>
<DisableSourceLink>false</DisableSourceLink>
</PropertyGroup>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<SourceLink>source-link.json</SourceLink>
<AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
<PathMap>$(AppOutputBase)=/fakepath/$(MSBuildProjectDirectory)</PathMap>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"documents": {
"/fakepath/*": ""
radical marked this conversation as resolved.
Show resolved Hide resolved
}
}