diff --git a/src/Sarif.Converters.UnitTests/ClangAnalyzerConverterTests.cs b/src/Sarif.Converters.UnitTests/ClangAnalyzerConverterTests.cs index ab327cd89..036ffdf5e 100644 --- a/src/Sarif.Converters.UnitTests/ClangAnalyzerConverterTests.cs +++ b/src/Sarif.Converters.UnitTests/ClangAnalyzerConverterTests.cs @@ -38,7 +38,7 @@ public void ClangAnalyzerConverter_Convert_NullLogTest() ""runs"": [ { ""tool"": { - ""name"": ""Clang"" + ""name"": ""Clang Analyzer"" }, ""columnKind"": ""utf16CodeUnits"", ""results"": [] diff --git a/src/Sarif.Converters.UnitTests/ConverterTestsBase.cs b/src/Sarif.Converters.UnitTests/ConverterTestsBase.cs index 91d676eeb..37d902be1 100644 --- a/src/Sarif.Converters.UnitTests/ConverterTestsBase.cs +++ b/src/Sarif.Converters.UnitTests/ConverterTestsBase.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.Sarif.Converters; using Microsoft.CodeAnalysis.Sarif.TestUtilities; +using Microsoft.CodeAnalysis.Sarif.Writers; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -13,6 +14,7 @@ namespace Microsoft.CodeAnalysis.Sarif { public SarifLog RunTestCase(string inputData, string expectedResult, bool prettyPrint = true) { + PrereleaseCompatibilityTransformer.UpdateToCurrentVersion(expectedResult, forceUpdate: false, formatting: Formatting.Indented, out expectedResult); var converter = new T(); // First retrieve converter JSON. This code will raise appropriate exceptions diff --git a/src/Sarif.TestUtilities/AssertionExtensions.cs b/src/Sarif.TestUtilities/AssertionExtensions.cs index 8d6fcbf72..0861d9281 100644 --- a/src/Sarif.TestUtilities/AssertionExtensions.cs +++ b/src/Sarif.TestUtilities/AssertionExtensions.cs @@ -17,17 +17,12 @@ public static AndConstraint BeCrossPlatformEquivalent( { Execute.Assertion .ForCondition( - string.Equals(RemoveLineEndings(expected), RemoveLineEndings(assertion.Subject), StringComparison.OrdinalIgnoreCase) + FileDiffingTests.AreEquivalentSarifLogs(actualSarif: assertion.Subject, expected) ) .BecauseOf(because, becauseArgs) .FailWith(TestUtilityResources.BeCrossPlatformEquivalentError); return new AndConstraint(assertion); } - - private static string RemoveLineEndings(string input) - { - return Regex.Replace(input, @"\s+", ""); - } } } diff --git a/src/Sarif.TestUtilities/FileDiffingTests.cs b/src/Sarif.TestUtilities/FileDiffingTests.cs index 3e257ef67..de5174b89 100644 --- a/src/Sarif.TestUtilities/FileDiffingTests.cs +++ b/src/Sarif.TestUtilities/FileDiffingTests.cs @@ -198,7 +198,7 @@ protected static string GenerateDiffCommand(string suiteName, string expected, s return fullPath; } - protected static bool AreEquivalentSarifLogs(string actualSarif, string expectedSarif, IContractResolver contractResolver = null) + public static bool AreEquivalentSarifLogs(string actualSarif, string expectedSarif, IContractResolver contractResolver = null) { expectedSarif = expectedSarif ?? "{}";