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

SLVS-1697 Integrate Reproducer command with SLCore analysis #5905

Merged
Merged
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions src/SLCore.UnitTests/Analysis/SLCoreAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

using NSubstitute.ExceptionExtensions;
using SonarLint.VisualStudio.CFamily.Analysis;
using SonarLint.VisualStudio.Core;
using SonarLint.VisualStudio.Core.Analysis;
using SonarLint.VisualStudio.Core.CFamily;
Expand Down Expand Up @@ -182,6 +183,23 @@ public void ExecuteAnalysis_ForCFamily_PassesCompilationDatabaseAsExtraPropertie
compilationDatabaseHandle.Received().Dispose();
}

[TestMethod]

Choose a reason for hiding this comment

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

Please also add a test case for when the reproducer is not enabled.

public void ExecuteAnalysis_CFamilyReproducerEnabled_SetsExtraProperty()
{
const string filePath = @"C:\file\path\myclass.cpp";
SetUpCompilationDatabaseLocator(filePath, CreateCompilationDatabaseHandle("somepath"));
SetUpInitializedConfigScope();
var cFamilyAnalyzerOptions = Substitute.For<ICFamilyAnalyzerOptions>();
cFamilyAnalyzerOptions.CreateReproducer.Returns(true);

testSubject.ExecuteAnalysis(filePath, analysisId, [AnalysisLanguage.CFamily], cFamilyAnalyzerOptions, default);

analysisService.Received().AnalyzeFilesAndTrackAsync(Arg.Is<AnalyzeFilesAndTrackParams>(a =>
a.extraProperties != null
&& a.extraProperties["sonar.cfamily.reproducer"] == filePath),
Arg.Any<CancellationToken>());
}

[TestMethod]
public void ExecuteAnalysis_ForCFamily_AnalysisThrows_CompilationDatabaaseDisposed()
{
Expand Down