Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a regex matching bug. #217

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ public static bool CommandsExecuted(this InMemoryProcessManager processManager,
// expression. If this does not resolve a match, we use the regular expression. This enables developers to
// use either exact matches or regular expression matches as they see fit.
IProcessProxy matchingProcess = processManager.Processes.FirstOrDefault(
proc => (proc.FullCommand() == command || Regex.IsMatch(proc.FullCommand(), command, RegexOptions.IgnoreCase))
proc => (proc.FullCommand() == command));

matchingProcess ??= processManager.Processes.FirstOrDefault(
proc => Regex.IsMatch(proc.FullCommand(), command, RegexOptions.IgnoreCase)
&& !processesConfirmed.Any(otherProc => object.ReferenceEquals(proc, otherProc)));

if (matchingProcess == null)
Expand Down Expand Up @@ -119,6 +122,10 @@ public static bool CommandsExecutedInWorkingDirectory(this InMemoryProcessManage
foreach (string command in commands)
{
IProcessProxy matchingProcess = processManager.Processes.FirstOrDefault(
proc => (proc.FullCommand() == command
&& proc.StartInfo.WorkingDirectory == workingDir));

matchingProcess ??= processManager.Processes.FirstOrDefault(
proc => Regex.IsMatch(proc.FullCommand(), command, RegexOptions.IgnoreCase)
&& proc.StartInfo.WorkingDirectory == workingDir
&& !processesConfirmed.Any(otherProc => object.ReferenceEquals(proc, otherProc)));
Expand Down