diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs index 26066bbb7a09a..ff915c066c662 100644 --- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs +++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs @@ -4798,7 +4798,11 @@ public void UnableWriteOutput_OutputFileLocked() 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}"); + if (!match.Success) + { + Assert.Fail($"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 cef3e0c201746..78575e9150d8c 100644 --- a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb +++ b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb @@ -5061,7 +5061,10 @@ End Class 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}") + If Not match.Success Then + Assert.Fail($"Expected:{Environment.NewLine}{pattern}{Environment.NewLine}Actual:{Environment.NewLine}{output}") + End If + Assert.Equal(filePath, match.Groups("path").Value) Assert.Contains("testhost", match.Groups("app").Value) Assert.Equal(currentProcess.Id, Integer.Parse(match.Groups("pid").Value))