Skip to content

Commit

Permalink
[wasm][tests] Enable line numbers in stack traces
Browse files Browse the repository at this point in the history
Library tests don't show line numbers, essentially because the .pdb
files never become available to the WasmAppBuilder .

This is enabled by default for `Debug` builds only.

To use it with `Release` builds, add `/p:DebuggerSupport=true` to the
command line.

With the patch:

```
  fail: [FAIL] System.Reflection.Tests.MemberInfoTests.HasSameMetadataDefinitionAs__CornerCase_HasElementTypes
  info: Assert.All() Failure: 10 out of 10 items in the collection did not pass.
  info: [9]: Item: System.Double*
  info:      Xunit.Sdk.AllException: Assert.All() Failure: 2 out of 10 items in the collection did not pass.
  info:      [7]: Item: System.Double&
  info:           Xunit.Sdk.TrueException: Assert.True() Failure
  info:           Expected: True
  info:           Actual:   False
  info:              at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95
  info:              at Xunit.Assert.True(Boolean condition) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 62
  info:              at System.Reflection.Tests.MemberInfoTests.<>c__DisplayClass31_1.<HasSameMetadataDefinitionAs__CornerCase_HasElementTypes>b__1(Type t2) in /Users/radical/dev/runtime/src/libraries/System.Reflection/tests/MemberInfoTests.cs:line 491
  info:              at Xunit.Assert.All[Type](IEnumerable`1 collection, Action`1 action) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\CollectionAsserts.cs:line 36
```
  • Loading branch information
radical committed Apr 9, 2021
1 parent 01b7e73 commit 2245483
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/workflow/testing/libraries/testing-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ At the moment supported values are:
By default, `chrome` browser is used.
## Debugging
### Getting more information
- Line numbers: add `/p:DebuggerSupport=true` to the command line, for `Release` builds. It's enabled by default for `Debug` builds.
## Kicking off outer loop tests from GitHub Interface
Add the following to the comment of a PR.
Expand Down
21 changes: 20 additions & 1 deletion eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- We need to set this in order to get extensibility on xunit category traits and other arguments we pass down to xunit via MSBuild properties -->
<PropertyGroup>
<BundleTestAppTargets>$(BundleTestAppTargets);BundleTestWasmApp</BundleTestAppTargets>
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' == 'Debug'">true</DebuggerSupport>
</PropertyGroup>

<PropertyGroup Condition="'$(RunScriptCommand)' == ''">
Expand All @@ -27,7 +28,9 @@
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<DebuggerSupport>false</DebuggerSupport>

<!-- we want to default to what Blazor has, except if we are building in Debug config -->
<DebuggerSupport Condition="'$(Configuration)' != 'Debug'">false</DebuggerSupport>
</PropertyGroup>

<!-- Don't include InTree.props here, because the test projects themselves can set the target* properties -->
Expand Down Expand Up @@ -62,6 +65,9 @@
<WasmInvariantGlobalization>$(InvariantGlobalization)</WasmInvariantGlobalization>
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
<WasmNativeStrip>false</WasmNativeStrip>

<WasmNativeDebugSymbols Condition="'$(DebuggerSupport)' == 'true' and '$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
<WasmDebugLevel Condition="'$(DebuggerSupport)' == 'true' and '$(WasmDebugLevel)' == ''">-1</WasmDebugLevel>
</PropertyGroup>

<ItemGroup>
Expand All @@ -79,4 +85,17 @@
<WasmFilesToIncludeInFileSystem Include="@(WasmFilesToIncludeFromPublishDir -> '$(PublishDir)%(Identity)')" />
</ItemGroup>
</Target>

<!-- linker automatically picks up the .pdb files, but they are not added to the publish list.
Add them explicitly here, so they can be used with WasmAppBuilder -->
<Target Name="AddPdbFilesToPublishList" AfterTargets="ILLink" Condition="'$(DebuggerSupport)' == 'true'">
<ItemGroup>
<_PdbFilesToCheck Include="$([System.IO.Path]::ChangeExtension('%(ResolvedFileToPublish.Identity)', '.pdb'))"
Condition="'%(ResolvedFileToPublish.Extension)' == '.dll'" />

<ResolvedFileToPublish Include="@(_PdbFilesToCheck)"
Condition="Exists(%(_PdbFilesToCheck.Identity))"
RelativePath="%(_PdbFilesToCheck.FileName)%(_PdbFilesToCheck.Extension)" />
</ItemGroup>
</Target>
</Project>
5 changes: 5 additions & 0 deletions src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
- $(WasmNativeStrip) - Whenever to strip the native executable. Defaults to true.
- $(WasmLinkIcalls) - Whenever to link out unused icalls. Defaults to $(WasmBuildNative).
- $(RunAOTCompilation) - Defaults to false.
- $(WasmDebugLevel)
> 0 enables debugging and sets the debug log level to debug_level
== 0 disables debugging and enables interpreter optimizations
< 0 enabled debugging and disables debug logging.
- $(WasmNativeDebugSymbols) - Build with native debug symbols, useful only with `$(RunAOTCompilation)`, or `$(WasmBuildNative)`
Defaults to true.
- $(WasmDedup) - Whenever to dedup generic instances when using AOT. Defaults to true.
Expand Down

0 comments on commit 2245483

Please sign in to comment.