]> source.dussan.org Git - sonarqube.git/commitdiff
Fix unit tests for windows
authorphilippe-perrin-sonarsource <philippe.perrin@sonarsource.com>
Fri, 26 Jul 2019 12:39:35 +0000 (14:39 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 30 Jul 2019 18:24:27 +0000 (20:24 +0200)
server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java

index 31cb90d41152727ff27a61fd648cfdca275b2c42..04ea9a5ce7874c9328092f5b0e06d392f6f4c56e 100644 (file)
@@ -162,11 +162,7 @@ public class EsInstallationTest {
 
     EsInstallation underTest = new EsInstallation(props);
 
-    if (System.getProperty("os.name").startsWith("Windows")) {
-      assertThat(underTest.getExecutable()).isEqualTo(new File(sqHomeDir, "elasticsearch/bin/elasticsearch.bat"));
-    } else {
-      assertThat(underTest.getExecutable()).isEqualTo(new File(sqHomeDir, "elasticsearch/bin/elasticsearch"));
-    }
+    assertThat(underTest.getExecutable()).isEqualTo(new File(sqHomeDir, "elasticsearch/bin/elasticsearch"));
   }
 
   @Test
index fbf775cbcb939cdc9d75566a7d4daf792bc022a2..29c09f7a81d193cca8065c890af552ab04489146 100644 (file)
@@ -804,15 +804,16 @@ public class FileSystemMediumTest {
   @Test
   public void scanProjectWithWrongCase() {
     // To please the quality gate, don't use assumeTrue, or the test will be reported as skipped
-    if (System2.INSTANCE.isOsWindows()) {
-      File projectDir = new File("test-resources/mediumtest/xoo/sample");
-      AnalysisResult result = tester
-        .newAnalysis(new File(projectDir, "sonar-project.properties"))
-        .property("sonar.sources", "XOURCES")
-        .property("sonar.tests", "TESTX")
-        .execute();
+    File projectDir = new File("test-resources/mediumtest/xoo/sample");
+    ScannerMediumTester.AnalysisBuilder analysis = tester
+      .newAnalysis(new File(projectDir, "sonar-project.properties"))
+      .property("sonar.sources", "XOURCES")
+      .property("sonar.tests", "TESTX");
+
+    if (System2.INSTANCE.isOsWindows()) { // Windows is file path case-insensitive
+      AnalysisResult result = analysis.execute();
 
-      assertThat(result.inputFiles()).hasSize(3);
+      assertThat(result.inputFiles()).hasSize(8);
       assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly(
         "testx/ClassOneTest.xoo.measures",
         "xources/hello/helloscala.xoo.measures",
@@ -822,6 +823,10 @@ public class FileSystemMediumTest {
         "xources/hello/helloscala.xoo",
         "testx/ClassOneTest.xoo.scm",
         "xources/hello/HelloJava.xoo");
+    } else { // Other OS are case-sensitive so an exception should be thrown
+      thrown.expect(MessageException.class);
+      thrown.expectMessage("The folder 'TESTX' does not exist for 'sample'");
+      analysis.execute();
     }
   }