Skip to content

Commit

Permalink
Fix Java ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Aug 12, 2024
1 parent 32d4351 commit 6ef1736
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 10 additions & 3 deletions its/src/test/java/com/sonar/it/csharp/AnalysisWarningsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,29 @@ void analysisWarningsImport() throws IOException {

Ce.Task task = TestUtils.getAnalysisWarningsTask(ORCHESTRATOR, buildResult);
assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS);
assertThat(task.getWarningsList()).containsExactly("First message", "Second message");
assertThat(task.getWarningsList()).containsExactly(
"First message",
"Second message",
"Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step.");
}

@Test
void analysisWarnings_MSBuild14() throws IOException {
BuildResult buildResult = Tests.analyzeProject(temp, "Roslyn.1.3.2");
Ce.Task task = TestUtils.getAnalysisWarningsTask(ORCHESTRATOR, buildResult);
assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS);
assertThat(task.getWarningsList()).containsExactly("The analysis using MsBuild 14 is no longer supported and the analysis with MsBuild 15 is deprecated. Please update your pipeline to MsBuild 16 or higher.");
assertThat(task.getWarningsList()).containsExactly(
"The analysis using MsBuild 14 is no longer supported and the analysis with MsBuild 15 is deprecated. Please update your pipeline to MsBuild 16 or higher.",
"Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step.");
}

@Test
void analysisWarnings_MSBuild15() throws IOException {
BuildResult buildResult = Tests.analyzeProject(temp, "Roslyn.2.4.0");
Ce.Task task = TestUtils.getAnalysisWarningsTask(ORCHESTRATOR, buildResult);
assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS);
assertThat(task.getWarningsList()).containsExactly("The analysis using MsBuild 15 is deprecated. Please update your pipeline to MsBuild 16 or higher.");
assertThat(task.getWarningsList()).containsExactly(
"The analysis using MsBuild 15 is deprecated. Please update your pipeline to MsBuild 16 or higher.",
"Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step.");
}
}
3 changes: 2 additions & 1 deletion its/src/test/java/com/sonar/it/shared/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public static void verifyGuiTestOnlyProjectAnalysisWarning(Orchestrator orchestr
+ " and no MAIN-code for any language, so only TEST-code related results are imported. "
+ "Many of our rules (e.g. vulnerabilities) are raised only on MAIN-code. "
+ "Read more about how the SonarScanner for .NET detects test projects: "
+ "https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects");
+ "https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects",
"Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step.");
}

public static Ce.Task getAnalysisWarningsTask(Orchestrator orchestrator, BuildResult buildResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public void logsContainInfo() {
.contains("WARN: SonarScanner for .NET detected only TEST files and no MAIN files for C# in the current solution. " +
"Only TEST-code related results will be imported to your SonarQube/SonarCloud project. " +
"Many of our rules (e.g. vulnerabilities) are raised only on MAIN-code. " +
"Read more about how the SonarScanner for .NET detects test projects: https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects");
"Read more about how the SonarScanner for .NET detects test projects: https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects",
"Multi-Language analysis is enabled. If this was not intended, please set \"/d:sonar.scanner.scanAll=false\" in the begin step.");

assertThat(buildResult.getLogsLines(l -> l.contains("INFO"))).contains(
"INFO: Found 1 MSBuild VB.NET project: 1 MAIN project.",
Expand Down

0 comments on commit 6ef1736

Please sign in to comment.