Skip to content

Commit 58c4a71

Browse files
committed
[IT] Complete fix of tests due to Orchestrator upgrade
1 parent d933eac commit 58c4a71

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

its/plugin/src/test/java/com/sonar/python/it/plugin/CoverageTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ public void empty_coverage_report() throws Exception {
126126
.setProperty("sonar.python.coverage.overallReportPath", "empty.xml");
127127
BuildResult buildResult = orchestrator.executeBuild(build);
128128

129-
assertThat(buildResult.getLogs()).matches(".*The report '[^']*' seems to be empty, ignoring.*");
129+
int nbLog = 0;
130+
for (String s : buildResult.getLogs().split("[\\r\\n]+")) {
131+
if (s.matches(".*The report '[^']*' seems to be empty, ignoring.*")) {
132+
nbLog++;
133+
}
134+
}
135+
assertThat(nbLog).isEqualTo(3);
130136
assertThat(getProjectMeasure(PROJECT_KEY, "coverage")).isNull();
131137
assertThat(getProjectMeasure(PROJECT_KEY, "it_coverage")).isNull();
132138
assertThat(getProjectMeasure(PROJECT_KEY, "overall_coverage")).isNull();

its/plugin/src/test/java/com/sonar/python/it/plugin/MetricsTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ public class MetricsTest {
4444

4545
@BeforeClass
4646
public static void startServer() {
47-
orchestrator.getServer().provisionProject("project", "project");
48-
orchestrator.getServer().associateProjectToQualityProfile("project", "py", "no_rule");
47+
orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY);
48+
orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "py", "no_rule");
4949
SonarRunner build = SonarRunner.create()
5050
.setProjectDir(new File("projects/metrics"))
5151
.setProjectKey(PROJECT_KEY)
5252
.setProjectName(PROJECT_KEY)
5353
.setProjectVersion("1.0-SNAPSHOT")
54-
.setProfile("no_rule")
5554
.setSourceDirs("src");
5655
orchestrator.executeBuild(build);
5756

its/plugin/src/test/java/com/sonar/python/it/plugin/PylintReportTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public void missing_report() throws Exception {
5757
@Test
5858
public void invalid_report() throws Exception {
5959
BuildResult result = analyseProjectWithReport("invalid.txt");
60-
assertThat(result.getLogs()).matches(".*DEBUG - Cannot parse the line: trash.*");
60+
assertThat(result.getLogs()).contains("DEBUG - Cannot parse the line: trash");
6161
assertThat(issues()).hasSize(0);
6262
}
6363

6464
@Test
6565
public void unknown_rule() throws Exception {
6666
BuildResult result = analyseProjectWithReport("rule-unknown.txt");
67-
assertThat(result.getLogs()).matches(".*WARN - Pylint rule 'C9999' is unknown.*");
67+
assertThat(result.getLogs()).contains("WARN - Pylint rule 'C9999' is unknown");
6868
assertThat(issues()).hasSize(0);
6969
}
7070

@@ -74,12 +74,10 @@ private List<Issue> issues() {
7474

7575
private BuildResult analyseProjectWithReport(String reportPath) {
7676
orchestrator.resetData();
77-
orchestrator.getServer().provisionProject("pylint_project", "pylint_project");
78-
orchestrator.getServer().associateProjectToQualityProfile("pylint_project", "py", "pylint-rules");
77+
orchestrator.getServer().provisionProject(PROJECT, PROJECT);
78+
orchestrator.getServer().associateProjectToQualityProfile(PROJECT, "py", "pylint-rules");
7979
return orchestrator.executeBuild(
8080
SonarRunner.create()
81-
.setProjectKey("pylint_project")
82-
.setProjectName("pylint_project")
8381
.setDebugLogs(true)
8482
.setProjectDir(new File("projects/pylint_project"))
8583
.setProperty("sonar.python.pylint.reportPath", reportPath));

its/plugin/src/test/java/com/sonar/python/it/plugin/TestReportTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void missing_test_report_with_simple_mode() throws Exception {
9494
public void invalid_test_report() throws Exception {
9595
BuildResult result = orchestrator.executeBuildQuietly(createBuild("invalid_report.xml"));
9696
assertThat(result.isSuccess()).isFalse();
97-
assertThat(result.getLogs()).matches(".*Cannot feed the data into sonar.*");
97+
assertThat(result.getLogs()).contains("Cannot feed the data into sonar");
9898
assertProjectMeasures(PROJECT, nullMeasures());
9999
}
100100

0 commit comments

Comments
 (0)