Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ec511de

Browse files
maryamariyanstephentoub
authored andcommitted
Fixing System.Diagnostics.Tests.ProcessTests failures on Unix (#27670)
* Fixing System.Diagnostics.Tests.ProcessTests failures on Unix Making sure we throw InvalidOperationException and with proper message to be consistent with netfx. This fixes test HandleCountChanges and updates two other existing tests Making s_allowedProgramsToRun field static in order to fix the 'field marshalling' error occuring during RemoteInvoke Fixes #27459 * Changing back to existing exception type and correcting the test method accordingly
1 parent 4ca662c commit ec511de

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/System.Diagnostics.Process/tests/ProcessTests.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,6 @@ private void RunTestAsSudo(Func<string, int> testMethod, string arg)
592592
[DllImport("libc")]
593593
private static extern int seteuid(uint euid);
594594

595-
private readonly string[] s_allowedProgramsToRun = new string[] { "xdg-open", "gnome-open", "kfmclient" };
595+
private static readonly string[] s_allowedProgramsToRun = new string[] { "xdg-open", "gnome-open", "kfmclient" };
596596
}
597597
}

src/System.Diagnostics.Process/tests/ProcessTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,10 @@ public void GetProcesses_EmptyMachineName_ThrowsArgumentException()
923923

924924
[Fact]
925925
[ActiveIssue(26720, TargetFrameworkMonikers.Uap)]
926-
[ActiveIssue(27459)]
927926
public void GetProcesses_InvalidMachineName_ThrowsInvalidOperationException()
928927
{
929-
Assert.Throws<InvalidOperationException>(() => Process.GetProcesses(Guid.NewGuid().ToString()));
928+
Type exceptionType = PlatformDetection.IsWindows ? typeof(InvalidOperationException) : typeof(PlatformNotSupportedException);
929+
var exception = Assert.Throws(exceptionType, () => Process.GetProcesses(Guid.NewGuid().ToString()));
930930
}
931931

932932
[Fact]
@@ -1285,7 +1285,6 @@ public void TestHandleCount_OSX()
12851285
[PlatformSpecific(TestPlatforms.Linux | TestPlatforms.Windows)] // Expected process HandleCounts differs on OSX
12861286
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Handle count change is not reliable, but seems less robust on NETFX")]
12871287
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Retrieving information about local processes is not supported on uap")]
1288-
[ActiveIssue(27459)]
12891288
public void HandleCountChanges()
12901289
{
12911290
RemoteInvoke(() =>

0 commit comments

Comments
 (0)