tmf: Skip TestTraceOffsetting on Mac OS X 10.11.1 because of bug 481611
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 24 Nov 2015 22:51:53 +0000 (17:51 -0500)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Mon, 30 Nov 2015 23:28:03 +0000 (18:28 -0500)
This is a work around for now, until 481611 is fixed.

Change-Id: Ifb95491107d20941a554f37f20728186a18c6760
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/61201
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/TestTraceOffsetting.java

index b8e1392bcef2aaea7bbb818aed5b4c977310dc16..57f26de5c4e7583f0d7e387921353b0f5313437c 100644 (file)
 package org.eclipse.tracecompass.tmf.ui.swtbot.tests.viewers.events;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.log4j.ConsoleAppender;
 import org.apache.log4j.Logger;
@@ -26,6 +29,7 @@ import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
 import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
 import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -109,6 +113,12 @@ public class TestTraceOffsetting {
      */
     @Test
     public void testOffsetting() {
+        // Skip this test on Mac OS X 10.11.1 because of bug 481611
+        // FIXME: Remove this work around once bug 481611 is fixed
+        MacOsVersion macOsVersion = MacOsVersion.getMacOsVersion();
+        boolean macBugPresent = macOsVersion != null && macOsVersion.compareTo(new MacOsVersion(10, 11, 1)) >= 0;
+        assumeTrue(!macBugPresent);
+
         SWTBotUtils.createProject(PROJET_NAME);
         SWTBotTreeItem traceFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
         SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
@@ -145,4 +155,76 @@ public class TestTraceOffsetting {
         SWTBotUtils.deleteProject(PROJET_NAME, fBot);
     }
 
+    /**
+     * Class to store the Mac OS version.
+     *
+     * This could be moved if other tests start using this.
+     */
+    private static class MacOsVersion implements Comparable<MacOsVersion> {
+        private static final Pattern MAC_OS_VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)");
+
+        private int fMajorVersion;
+        private int fMinorVersion;
+        private int fBugFixVersion;
+
+        private static MacOsVersion fRunningMacOsVersion;
+
+        private MacOsVersion(int version, int majorVersion, int patchVersion) {
+            this.fMajorVersion = version;
+            this.fMinorVersion = majorVersion;
+            this.fBugFixVersion = patchVersion;
+        }
+
+        private int getMajorVersion() {
+            return fMajorVersion;
+        }
+
+        private int getMinorVersion() {
+            return fMinorVersion;
+        }
+
+        private int getBugFixVersion() {
+            return fBugFixVersion;
+        }
+
+        private static MacOsVersion getMacOsVersion() {
+            if (fRunningMacOsVersion != null) {
+                return fRunningMacOsVersion;
+            }
+
+            if (!SWTUtils.isMac()) {
+                return null;
+            }
+
+            String osVersion = System.getProperty("os.version");
+            if (osVersion == null) {
+                return null;
+            }
+            Matcher matcher = MAC_OS_VERSION_PATTERN.matcher(osVersion);
+            if (matcher.matches()) {
+                try {
+                    fRunningMacOsVersion = new MacOsVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)));
+                    return fRunningMacOsVersion;
+                } catch (NumberFormatException e) {
+                    // ignore
+                }
+            }
+            return null;
+        }
+
+        @Override
+        public int compareTo(MacOsVersion o) {
+            int compareTo = Integer.compare(fMajorVersion, o.getMajorVersion());
+            if (compareTo != 0) {
+                return compareTo;
+            }
+
+            compareTo = Integer.compare(fMinorVersion, o.getMinorVersion());
+            if (compareTo != 0) {
+                return compareTo;
+            }
+
+            return Integer.compare(fBugFixVersion, o.getBugFixVersion());
+        }
+    }
 }
\ No newline at end of file
This page took 0.027095 seconds and 5 git commands to generate.