This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 50f8c30  [TRAVIS] Compile and run tests in macOS
     new 3c2841a  Merge pull request #1821 from blackleg/macos
50f8c30 is described below

commit 50f8c3002834c50c5d28af0b331c5d88fdde5308
Author: Hector Espert <[email protected]>
AuthorDate: Thu Dec 26 12:41:09 2019 +0100

    [TRAVIS] Compile and run tests in macOS
---
 .travis.yml                                        | 17 ++++++
 .../utils/hname/mac/HostnameUtilsMacTest.java      | 45 ++++++++++++++
 .../watcher/linux/LinuxNotifier235632Test.java     | 10 ++--
 platform/masterfs.macosx/nbproject/project.xml     | 17 ++++++
 .../masterfs/watcher/macosx/OSXNotifierTest.java}  | 68 ++++++----------------
 5 files changed, 102 insertions(+), 55 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 13008df..1c2f4a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -472,3 +472,20 @@ matrix:
             - ant $OPTS -f php/php.composer test
             #- ant $OPTS -f php/php.dbgp test
             - ant $OPTS -f php/php.doctrine2 test
+            
+        - name: MacOS tests
+          language: java
+          os: osx
+          jdk: openjdk11
+          addons:
+            homebrew:
+              packages:
+                - ant
+          env:
+            - OPTS="-silent -Dcluster.config=platform 
-Dpermit.jdk9.builds=true -Djavac.compilerargs=-nowarn 
-Dbuild.compiler.deprecation=false 
-Dtest-unit-sys-prop.ignore.random.failures=true -Dvanilla.javac.exists=true"
+          before_script:
+            - ant $OPTS clean
+            - ant $OPTS build
+          script:
+            - ant $OPTS -f platform/masterfs.macosx test
+            - ant $OPTS -f platform/core.network test
diff --git 
a/platform/core.network/test/unit/src/org/netbeans/core/network/utils/hname/mac/HostnameUtilsMacTest.java
 
b/platform/core.network/test/unit/src/org/netbeans/core/network/utils/hname/mac/HostnameUtilsMacTest.java
new file mode 100644
index 0000000..874310f
--- /dev/null
+++ 
b/platform/core.network/test/unit/src/org/netbeans/core/network/utils/hname/mac/HostnameUtilsMacTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.core.network.utils.hname.mac;
+
+import com.sun.jna.Platform;
+import org.junit.Test;
+import org.netbeans.junit.NbTestCase;
+
+/**
+ *
+ * @author Hector Espert
+ */
+public class HostnameUtilsMacTest extends NbTestCase {
+
+    public HostnameUtilsMacTest(String name) {
+        super(name);
+    }
+
+    @Override
+    public boolean canRun() {
+        return super.canRun() && Platform.isMac();
+    }
+    
+    @Test
+    public void testCLibGetHostname() throws Exception {
+        assertNotNull(HostnameUtilsMac.cLibGetHostname());
+    }
+    
+}
diff --git 
a/platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
 
b/platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
index 3a7c17d..dd15c72 100644
--- 
a/platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
+++ 
b/platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
@@ -56,6 +56,11 @@ public class LinuxNotifier235632Test extends NbTestCase {
         clearWorkDir();
     }
 
+    @Override
+    public boolean canRun() {
+        return super.canRun() && Utilities.getOperatingSystem() == 
Utilities.OS_LINUX;
+    }
+
     /**
      * Prepare folders and files for testing.
      *
@@ -90,11 +95,6 @@ public class LinuxNotifier235632Test extends NbTestCase {
      */
     public void testNextEvent() throws Exception {
 
-        if (Utilities.getOperatingSystem() != Utilities.OS_LINUX) {
-            System.out.println("Skipping linux-only test: " + getName());
-            return;
-        }
-
         prepareFiles();
 
         final AtomicBoolean folder2refreshed = new AtomicBoolean(false);
diff --git a/platform/masterfs.macosx/nbproject/project.xml 
b/platform/masterfs.macosx/nbproject/project.xml
index 07121bd..8f12405 100644
--- a/platform/masterfs.macosx/nbproject/project.xml
+++ b/platform/masterfs.macosx/nbproject/project.xml
@@ -49,6 +49,23 @@
                     <compile-dependency/>
                 </dependency>
             </module-dependencies>
+            <test-dependencies>
+                <test-type>
+                    <name>unit</name>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.insane</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        
<code-name-base>org.netbeans.libs.junit4</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                </test-type>
+            </test-dependencies>
             <public-packages/>
         </data>
     </configuration>
diff --git 
a/platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
 
b/platform/masterfs.macosx/test/unit/src/org/netbeans/modules/masterfs/watcher/macosx/OSXNotifierTest.java
similarity index 72%
copy from 
platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
copy to 
platform/masterfs.macosx/test/unit/src/org/netbeans/modules/masterfs/watcher/macosx/OSXNotifierTest.java
index 3a7c17d..c7f0e4b 100644
--- 
a/platform/masterfs.linux/test/unit/src/org/netbeans/modules/masterfs/watcher/linux/LinuxNotifier235632Test.java
+++ 
b/platform/masterfs.macosx/test/unit/src/org/netbeans/modules/masterfs/watcher/macosx/OSXNotifierTest.java
@@ -16,15 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.netbeans.modules.masterfs.watcher.linux;
+package org.netbeans.modules.masterfs.watcher.macosx;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
+import static junit.framework.TestCase.assertFalse;
+import org.junit.Test;
 import org.netbeans.junit.Log;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj;
@@ -35,40 +36,29 @@ import org.openide.filesystems.FileUtil;
 import org.openide.util.Utilities;
 
 /**
- * Test for bug 235632.
- *
- * @author jhavlin
+ * Test based in the LinuxNotifier235632Test test class
+ * @author Hector Espert
  */
-public class LinuxNotifier235632Test extends NbTestCase {
-
+public class OSXNotifierTest extends NbTestCase {
+    
     private File folder1;
     private File folder1text1Txt;
     private FileObject folder2FO;
     private FileObject folder2text2TxtFO;
 
-    public LinuxNotifier235632Test(String testName) {
-        super(testName);
+    public OSXNotifierTest(String name) {
+        super(name);
     }
-
+    
+    @Override
+    public boolean canRun() {
+        return super.canRun() && Utilities.getOperatingSystem() == 
Utilities.OS_MAC;
+    }
+    
     @Override
     protected void setUp() throws Exception {
         Log.enable(FolderObj.class.getName(), Level.FINEST);
         clearWorkDir();
-    }
-
-    /**
-     * Prepare folders and files for testing.
-     *
-     * <pre>
-     * - folder1          (only java.io.File)
-     *    - text1.txt     (only java.io.File)
-     * - folder2          (FileObject)
-     *    - text2.txt     (FileObject, with registered listener)
-     * </pre>
-     *
-     * @throws IOException
-     */
-    private void prepareFiles() throws IOException {
         folder1 = new File(getWorkDir(), "folder1");
         folder1.mkdir();
         folder1text1Txt = new File(folder1, "text1.txt");
@@ -78,25 +68,12 @@ public class LinuxNotifier235632Test extends NbTestCase {
         folder2.mkdir();
         folder2FO = FileUtil.toFileObject(folder2);
         folder2text2TxtFO = folder2FO.createData("text2.txt");
-        // Causes the path to be registered in the notifier.
         folder2text2TxtFO.addFileChangeListener(new FileChangeAdapter());
         folder2FO.refresh();
     }
 
-    /**
-     * Test of nextEvent method, of class LinuxNotifier.
-     *
-     * @throws java.lang.Exception
-     */
+    @Test
     public void testNextEvent() throws Exception {
-
-        if (Utilities.getOperatingSystem() != Utilities.OS_LINUX) {
-            System.out.println("Skipping linux-only test: " + getName());
-            return;
-        }
-
-        prepareFiles();
-
         final AtomicBoolean folder2refreshed = new AtomicBoolean(false);
         Logger log = Logger.getLogger(FolderObj.class.getName());
 
@@ -105,9 +82,7 @@ public class LinuxNotifier235632Test extends NbTestCase {
         try {
             FileChangeListener l = new FileChangeAdapter();
             FileUtil.addFileChangeListener(l, folder1text1Txt);
-            // This causes an IN_IGNORED native event.
             FileUtil.removeFileChangeListener(l, folder1text1Txt);
-            // Native listeners may need some time.
             Thread.sleep(2000);
         } finally {
             log.removeHandler(h);
@@ -115,15 +90,7 @@ public class LinuxNotifier235632Test extends NbTestCase {
         assertFalse("Folder folder2 should not be refreshed.",
                 folder2refreshed.get());
     }
-
-    /**
-     * Create a logging handler that sets value in an AtomicBoolean to true if
-     * folder2 or text2.txt is refreshed.
-     *
-     * @param refreshedFlag The AtomicBoolean to be set to true if incorrect
-     * refreshing was triggered.
-     * @return The new logging handler.
-     */
+    
     private Handler createHandler(final AtomicBoolean refreshedFlag) {
         Handler h = new Handler() {
 
@@ -149,4 +116,5 @@ public class LinuxNotifier235632Test extends NbTestCase {
         };
         return h;
     }
+    
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to