Skip to content

Commit c674f52

Browse files
committed
SONARMSBRU-282 Starting the Scanner without parameters should not throw exception
1 parent 265095d commit c674f52

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

SonarQube.Bootstrapper/BootstrapperClass.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ private int PostProcess()
8282
Utilities.LogAssemblyVersion(Logger, typeof(Program).Assembly, Resources.AssemblyDescription);
8383
Logger.IncludeTimestamp = true;
8484

85+
if (!Directory.Exists(BootstrapSettings.TempDirectory))
86+
{
87+
Logger.LogError(Resources.ERROR_TempDirDoesNotExist);
88+
return ErrorCode;
89+
}
90+
8591
Directory.SetCurrentDirectory(BootstrapSettings.TempDirectory);
8692
ITeamBuildSettings teamBuildSettings = TeamBuildSettings.GetSettingsFromEnvironment(Logger);
8793
AnalysisConfig config = GetAnalysisConfig(teamBuildSettings.AnalysisConfigFilePath);

SonarQube.Bootstrapper/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SonarQube.Bootstrapper/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@
138138
<data name="ERROR_ProcessingFailed" xml:space="preserve">
139139
<value>{0} failed. Exit code: {1}</value>
140140
</data>
141+
<data name="ERROR_TempDirDoesNotExist" xml:space="preserve">
142+
<value>Temporary analysis directory (usually .sonarqube) doesn't exist. The "begin" step was probably not executed.</value>
143+
</data>
141144
<data name="ERROR_VersionMismatch" xml:space="preserve">
142145
<value>The C# plugin installed on the SonarQube server is not compatible with the SonarQube analysis agent (i.e. the MSBuild.SonarQube.Scanner.exe, or the build automation task). Either check the compatibility matrix or get the latest versions for both.</value>
143146
</data>

Tests/SonarQube.Bootstrapper.Tests/BootstrapperClassTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ public void Exe_PostProc_Fails()
170170
}
171171
}
172172

173+
[TestMethod]
174+
public void Exe_PostProc_Fails_On_Missing_TempFolder()
175+
{
176+
Directory.Delete(TempDir, true);
177+
178+
using (InitializeNonTeamBuildEnvironment(RootDir))
179+
{
180+
// Act
181+
TestLogger logger = CheckExecutionFails(AnalysisPhase.PostProcessing, false);
182+
183+
// Assert
184+
logger.AssertErrorsLogged(2);
185+
}
186+
}
187+
173188
[TestMethod]
174189
public void Exe_PostProc_Succeeds()
175190
{

0 commit comments

Comments
 (0)