Skip to content

Commit

Permalink
WASM: Fix System.Diagnostics.TextWriterTraceListener tests (dotnet#39186
Browse files Browse the repository at this point in the history
)

* WASM: Fix System.Diagnostics.TextWriterTraceListener tests

It was using Process.GetCurrentProcess() which throws PNSE on WebAssembly.

* PR feedback
  • Loading branch information
akoeplinger authored Jul 14, 2020
1 parent 4489582 commit a9b1173
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,15 @@ private void WriteEndHeader()
string? processName = s_processName;
if (processName is null)
{
using Process process = Process.GetCurrentProcess();
s_processName = processName = process.ProcessName;
try
{
using Process process = Process.GetCurrentProcess();
s_processName = processName = process.ProcessName;
}
catch (PlatformNotSupportedException) // Process isn't supported on Browser
{
s_processName = processName = string.Empty;
}
}

InternalWrite("\" />");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ public class XmlWriterTraceListenerTests : FileCleanupTestBase

public XmlWriterTraceListenerTests()
{
using (var process = Process.GetCurrentProcess())
try
{
_processName = process.ProcessName;
using (var process = Process.GetCurrentProcess())
{
_processName = process.ProcessName;
}
}
catch (PlatformNotSupportedException) // Process isn't supported on Browser
{
_processName = string.Empty;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ComponentModel.TypeConverter\tests\System.ComponentModel.TypeConverter.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Data.Common\tests\System.Data.Common.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Diagnostics.DiagnosticSource\tests\TestWithConfigSwitches\System.Diagnostics.DiagnosticSource.Switches.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Diagnostics.TextWriterTraceListener\tests\System.Diagnostics.TextWriterTraceListener.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Calendars\tests\CalendarTestWithConfigSwitch\System.Globalization.CalendarsWithConfigSwitch.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Calendars\tests\System.Globalization.Calendars.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Extensions\tests\System.Globalization.Extensions.Tests.csproj" />
Expand Down

0 comments on commit a9b1173

Please sign in to comment.