From b2b207faa18fd42daa8ca07be20488303f24141c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 21 Mar 2019 12:10:16 -0700 Subject: [PATCH] Allow some warnings (dotnet/aspnetcore-tooling#353) Fixes https://github.com/aspnet/AspNetCore-Internal/issues/2050\n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/e2b1df744e8ce4294488cf7270d4a01aeebf7d57 --- .../test/IntegrationTests/Assert.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs index deb92de412..d43d0e6d2c 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/Assert.cs @@ -19,6 +19,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // See https://stackoverflow.com/questions/3441452/msbuild-and-ignorestandarderrorwarningformat/5180353#5180353 private static readonly Regex ErrorRegex = new Regex(@"^(?'location'.+): error (?'errorcode'[A-Z0-9]+): (?'message'.+) \[(?'project'.+)\]$"); private static readonly Regex WarningRegex = new Regex(@"^(?'location'.+): warning (?'errorcode'[A-Z0-9]+): (?'message'.+) \[(?'project'.+)\]$"); + private static readonly string[] AllowedBuildWarnings = new[] + { + "MSB3491" , // The process cannot access the file. As long as the build succeeds, we're ok. + }; public static void BuildPassed(MSBuildResult result, bool allowWarnings = false) { @@ -32,7 +36,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw new BuildFailedException(result); } - var buildWarnings = GetBuildWarnings(result).Select(m => m.line); + var buildWarnings = GetBuildWarnings(result) + .Where(m => !AllowedBuildWarnings.Contains(m.match.Groups["errorcode"].Value)) + .Select(m => m.line); + if (!allowWarnings && buildWarnings.Any()) { throw new BuildWarningsException(result, buildWarnings);