Skip to content

Commit b4477a4

Browse files
Fixed a regex matching bug. (#217)
* fixed a regex matching bug * working dir --------- Co-authored-by: Yang Pan <[email protected]>
1 parent d27d57c commit b4477a4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/VirtualClient/VirtualClient.TestExtensions/DependencyFixtureExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ public static bool CommandsExecuted(this InMemoryProcessManager processManager,
9191
// expression. If this does not resolve a match, we use the regular expression. This enables developers to
9292
// use either exact matches or regular expression matches as they see fit.
9393
IProcessProxy matchingProcess = processManager.Processes.FirstOrDefault(
94-
proc => (proc.FullCommand() == command || Regex.IsMatch(proc.FullCommand(), command, RegexOptions.IgnoreCase))
94+
proc => (proc.FullCommand() == command));
95+
96+
matchingProcess ??= processManager.Processes.FirstOrDefault(
97+
proc => Regex.IsMatch(proc.FullCommand(), command, RegexOptions.IgnoreCase)
9598
&& !processesConfirmed.Any(otherProc => object.ReferenceEquals(proc, otherProc)));
9699

97100
if (matchingProcess == null)
@@ -119,6 +122,10 @@ public static bool CommandsExecutedInWorkingDirectory(this InMemoryProcessManage
119122
foreach (string command in commands)
120123
{
121124
IProcessProxy matchingProcess = processManager.Processes.FirstOrDefault(
125+
proc => (proc.FullCommand() == command
126+
&& proc.StartInfo.WorkingDirectory == workingDir));
127+
128+
matchingProcess ??= processManager.Processes.FirstOrDefault(
122129
proc => Regex.IsMatch(proc.FullCommand(), command, RegexOptions.IgnoreCase)
123130
&& proc.StartInfo.WorkingDirectory == workingDir
124131
&& !processesConfirmed.Any(otherProc => object.ReferenceEquals(proc, otherProc)));

0 commit comments

Comments
 (0)