Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clang analyzer name. Flow converter log verification through J… #1213

Merged
merged 1 commit into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void ClangAnalyzerConverter_Convert_NullLogTest()
""runs"": [
{
""tool"": {
""name"": ""Clang""
""name"": ""Clang Analyzer""
},
""columnKind"": ""utf16CodeUnits"",
""results"": []
Expand Down
2 changes: 2 additions & 0 deletions src/Sarif.Converters.UnitTests/ConverterTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrereleaseCompatibilityTransformer [](start = 12, length = 34)

Previously, we made manual updates to expected test results flowing through this helper.

var converter = new T();

// First retrieve converter JSON. This code will raise appropriate exceptions
Expand Down
7 changes: 1 addition & 6 deletions src/Sarif.TestUtilities/AssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ public static AndConstraint<StringAssertions> BeCrossPlatformEquivalent(
{
Execute.Assertion
.ForCondition(
string.Equals(RemoveLineEndings(expected), RemoveLineEndings(assertion.Subject), StringComparison.OrdinalIgnoreCase)
FileDiffingTests.AreEquivalentSarifLogs<SarifLog>(actualSarif: assertion.Subject, expected)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AreEquivalentSarifLogs [](start = 37, length = 22)

This helper is more resilient to whitespace-only differences in test files. Also DRYs things out a bit.

)
.BecauseOf(because, becauseArgs)
.FailWith(TestUtilityResources.BeCrossPlatformEquivalentError);

return new AndConstraint<StringAssertions>(assertion);
}

private static string RemoveLineEndings(string input)
{
return Regex.Replace(input, @"\s+", "");
}
}
}
2 changes: 1 addition & 1 deletion src/Sarif.TestUtilities/FileDiffingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected static string GenerateDiffCommand(string suiteName, string expected, s
return fullPath;
}

protected static bool AreEquivalentSarifLogs<T>(string actualSarif, string expectedSarif, IContractResolver contractResolver = null)
public static bool AreEquivalentSarifLogs<T>(string actualSarif, string expectedSarif, IContractResolver contractResolver = null)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AreEquivalentSarifLogs [](start = 27, length = 22)

this helper likely should belong somewhere else, not this base class. but maybe it should stay here, if we end up converting everything to a filediffing-derived test class. we'll keep an eye on it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string extension. actualSarif.IsSarifEquivalentOf(expectedSarif).


In reply to: 247995751 [](ancestors = 247995751)

{
expectedSarif = expectedSarif ?? "{}";

Expand Down