Skip to content

Commit

Permalink
better assert
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Nov 18, 2024
1 parent c0510e5 commit 1b5a49d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4796,8 +4796,9 @@ public void UnableWriteOutput_OutputFileLocked()
Assert.Equal(1, exitCode);
var output = outWriter.ToString().Trim();

var match = Regex.Match(output, @"error CS2012: Cannot open '(?<path>.*)' for writing -- (?<message>.*); file may be locked by '(?<app>.*)' \((?<pid>.*)\)");
Assert.True(match.Success);
var pattern = @"error CS2012: Cannot open '(?<path>.*)' for writing -- (?<message>.*); file may be locked by '(?<app>.*)' \((?<pid>.*)\)";
var match = Regex.Match(output, pattern);
Assert.True(match.Success, $"Expected:{Environment.NewLine}{pattern}{Environment.NewLine}Actual:{Environment.NewLine}{output}");
Assert.Equal(filePath, match.Groups["path"].Value);
Assert.Contains("testhost", match.Groups["app"].Value);
Assert.Equal(currentProcess.Id, int.Parse(match.Groups["pid"].Value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5059,8 +5059,9 @@ End Class
Assert.Equal(1, exitCode)
Dim output = outWriter.ToString().Trim()

Dim match = Regex.Match(output, "vbc : error BC2012: can't open '(?<path>.*)' for writing: (?<message>.*); file may be locked by '(?<app>.*)' \((?<pid>.*)\)")
Assert.True(match.Success)
Dim pattern = "vbc : error BC2012: can't open '(?<path>.*)' for writing: (?<message>.*); file may be locked by '(?<app>.*)' \((?<pid>.*)\)"
Dim match = Regex.Match(output, pattern)
Assert.True(match.Success, $"Expected:{Environment.NewLine}{pattern}{Environment.NewLine}Actual:{Environment.NewLine}{output}")
Assert.Equal(filePath, match.Groups("path").Value)
Assert.Contains("testhost", match.Groups("app").Value)
Assert.Equal(currentProcess.Id, Integer.Parse(match.Groups("pid").Value))
Expand Down

0 comments on commit 1b5a49d

Please sign in to comment.