]> source.dussan.org Git - sonarqube.git/commitdiff
Fix test to make it run on mac os (#1977)
authorJacek <52388493+jacek-poreda-sonarsource@users.noreply.github.com>
Thu, 1 Aug 2019 13:08:41 +0000 (15:08 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 1 Aug 2019 18:21:14 +0000 (20:21 +0200)
* fix test to make it run on mac os

sonar-plugin-api/src/main/java/org/sonar/api/utils/System2.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java

index 36dc553a74e94f648c0387125e5a954d3821b3e6..ed4ee20497c318893acd0eccdcd0da8219b0af84 100644 (file)
@@ -126,6 +126,13 @@ public class System2 {
     return SystemUtils.IS_OS_WINDOWS;
   }
 
+  /**
+   * True if this is Mac system.
+   */
+  public boolean isOsMac() {
+    return SystemUtils.IS_OS_MAC;
+  }
+
   /**
    * True if Java 7 or Java 8 runtime environment
    *
index 9a8526195eb5c92a8d20bf2c0460ba331c512e57..ec4d0aac177490269f3f725f4789dc01f195b0fe 100644 (file)
@@ -83,6 +83,11 @@ public class System2Test {
     assertThat(System2.INSTANCE.isOsWindows()).isEqualTo(SystemUtils.IS_OS_WINDOWS);
   }
 
+  @Test
+  public void testIsOsMac() {
+    assertThat(System2.INSTANCE.isOsMac()).isEqualTo(SystemUtils.IS_OS_MAC);
+  }
+
   @Test
   public void isJavaAtLeast17_always_returns_true() {
     assertThat(System2.INSTANCE.isJavaAtLeast17()).isTrue();
index 29c09f7a81d193cca8065c890af552ab04489146..70b06029ef137e9c2cea9576e1f6bcad31210ee6 100644 (file)
@@ -36,12 +36,12 @@ import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.SonarEdition;
 import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.PathUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.xoo.XooPlugin;
@@ -823,7 +823,20 @@ 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
+    } else if (System2.INSTANCE.isOsMac()) {
+      AnalysisResult result = analysis.execute();
+
+      assertThat(result.inputFiles()).hasSize(8);
+      assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly(
+        "TESTX/ClassOneTest.xoo.measures",
+        "XOURCES/hello/helloscala.xoo.measures",
+        "XOURCES/hello/HelloJava.xoo.measures",
+        "TESTX/ClassOneTest.xoo",
+        "XOURCES/hello/HelloJava.xoo.scm",
+        "XOURCES/hello/helloscala.xoo",
+        "TESTX/ClassOneTest.xoo.scm",
+        "XOURCES/hello/HelloJava.xoo");
+    } else {
       thrown.expect(MessageException.class);
       thrown.expectMessage("The folder 'TESTX' does not exist for 'sample'");
       analysis.execute();