Skip to content

Commit b4a22dd

Browse files
CopilotEvangelink
andcommitted
Add validation for dump directory existence and null checks
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
1 parent d53479c commit b4a22dd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public async Task OnTestHostProcessExitedAsync(ITestHostProcessInformation testH
6666
await _outputDisplay.DisplayAsync(this, new ErrorMessageOutputDeviceData(string.Format(CultureInfo.InvariantCulture, CrashDumpResources.CrashDumpProcessCrashedDumpFileCreated, testHostProcessInformation.PID)), cancellation).ConfigureAwait(false);
6767

6868
string expectedDumpFile = _netCoreCrashDumpGeneratorConfiguration.DumpFileNamePattern.Replace("%p", testHostProcessInformation.PID.ToString(CultureInfo.InvariantCulture));
69-
string dumpDirectory = Path.GetDirectoryName(expectedDumpFile)!;
69+
string? dumpDirectory = Path.GetDirectoryName(expectedDumpFile);
70+
if (string.IsNullOrEmpty(dumpDirectory) || !Directory.Exists(dumpDirectory))
71+
{
72+
await _outputDisplay.DisplayAsync(this, new ErrorMessageOutputDeviceData(string.Format(CultureInfo.InvariantCulture, CrashDumpResources.CannotFindExpectedCrashDumpFile, expectedDumpFile)), cancellation).ConfigureAwait(false);
73+
return;
74+
}
7075

7176
// Collect all dump files in the directory to capture crashes from child processes
7277
bool foundExpectedDump = false;

0 commit comments

Comments
 (0)