From 1b5a49d3c3587408d9b2dc231937c96dd3da5ca4 Mon Sep 17 00:00:00 2001 From: tmat Date: Sun, 17 Nov 2024 16:45:18 -0800 Subject: [PATCH] better assert --- src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs | 5 +++-- .../VisualBasic/Test/CommandLine/CommandLineTests.vb | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs index bbe2205756f48..26066bbb7a09a 100644 --- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs +++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs @@ -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 '(?.*)' for writing -- (?.*); file may be locked by '(?.*)' \((?.*)\)"); - Assert.True(match.Success); + var pattern = @"error CS2012: Cannot open '(?.*)' for writing -- (?.*); file may be locked by '(?.*)' \((?.*)\)"; + 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)); diff --git a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb index 0b691c173cde6..cef3e0c201746 100644 --- a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb +++ b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb @@ -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 '(?.*)' for writing: (?.*); file may be locked by '(?.*)' \((?.*)\)") - Assert.True(match.Success) + Dim pattern = "vbc : error BC2012: can't open '(?.*)' for writing: (?.*); file may be locked by '(?.*)' \((?.*)\)" + 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))