Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Change checks for exception message
  • Loading branch information
batzen committed Mar 27, 2021
commit 7e58fade961bd6330ac4892ba87d82d57dffa706
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace System.Diagnostics.Tests
[ActiveIssue("https://github.com/dotnet/runtime/issues/49568", typeof(PlatformDetection), nameof(PlatformDetection.IsMacOsAppleSilicon))]
public partial class ProcessTests : ProcessTestBase
{
private const string FailedToStartExpectedRegexPattern = "Failed to start '.*' with working directory '.*'\\.";

private class FinalizingProcess : Process
{
public static volatile bool WasFinalized;
Expand Down Expand Up @@ -219,7 +217,8 @@ public void TestStartWithBadWorkingDirectory()

Win32Exception e = Assert.Throws<Win32Exception>(() => Process.Start(psi));
Assert.NotEqual(0, e.NativeErrorCode);
Assert.Matches(FailedToStartExpectedRegexPattern + " The directory name is invalid\\.", e.Message);
Assert.Contains(program, e.Message);
Assert.Contains(workingDirectory, e.Message);
}
else
{
Expand All @@ -233,7 +232,7 @@ public void ProcessStart_UseShellExecute_OnWindows_OpenMissingFile_Throws()
{
string fileToOpen = Path.Combine(Environment.CurrentDirectory, "_no_such_file.TXT");
Win32Exception e = Assert.Throws<Win32Exception>(() => Process.Start(new ProcessStartInfo { UseShellExecute = true, FileName = fileToOpen }));
Assert.Matches(FailedToStartExpectedRegexPattern + " The system cannot find the file specified\\.", e.Message);
Assert.Contains(fileToOpen, e.Message);
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.HasWindowsShell))]
Expand Down Expand Up @@ -1395,7 +1394,7 @@ public void TestStartWithMissingFile(bool fullPath)

Win32Exception e = Assert.Throws<Win32Exception>(() => Process.Start(path));
Assert.NotEqual(0, e.NativeErrorCode);
Assert.Matches(FailedToStartExpectedRegexPattern + " The system cannot find the file specified\\.", e.Message);
Assert.Contains(path, e.Message);
}

[Fact]
Expand Down