JAL-3130 single class testing on CLI with ant [ -Dclass.name=path/from/classpath...
authorBen Soares <bsoares@dundee.ac.uk>
Fri, 14 Dec 2018 10:10:39 +0000 (10:10 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Fri, 14 Dec 2018 10:10:39 +0000 (10:10 +0000)
build-j11.xml
src/jalview/gui/AlignFrame.java
test/jalview/bin/CommandLineOperations.java

index d589cc3..6ed0b0f 100755 (executable)
     </testng>
   </target>
 
+  <target name="testngclass" depends="buildTests">
+    <condition property="propsSpecified">
+      <isset property="class.name" />
+    </condition>
+    <fail unless="propsSpecified" message="class.name property not specified."/>
+    <echo message="testng-groups is '${testng-groups}'" />
+    <testng outputDir="${reportDir}" haltOnFailure="false" groups="${testng-groups}" mode="testng" verbose="2">
+      <classpath>
+        <pathelement location="${testOutputDir}" />
+        <pathelement location="${clover.jar}" if:set="clover.jar"/>
+        <path refid="test.classpath" />
+      </classpath>
+      <jvmarg value="--module-path=${j11libDir}:${java.home}/jmods" if:set="java11"/>
+      <jvmarg value="--add-modules=java.se.ee" if:set="java9"/>
+      <jvmarg value="--illegal-access=warn" if:set="java9"/>
+      <classfileset dir="${testOutputDir}" includes="${class.name}" />
+    </testng>
+  </target>
+
   <target name="buildindices" depends="init, prepare" unless="help.uptodate">
     <replace value="${JALVIEW_VERSION}">
       <replacetoken><![CDATA[$$Version-Rel$$]]></replacetoken>
index 1433cd2..2b6d868 100644 (file)
@@ -1200,7 +1200,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             int count = 20;
             for (int i = 0; i < count; i++)
             {
-              Thread.sleep(1000);
+              // Thread.sleep(1000);
               out.println("; TEST: " + (count - 1 - i));
             }
           }
@@ -2734,8 +2734,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (viewport.getViewName() == null)
     {
-      viewport.setViewName(MessageManager
-              .getString("label.view_name_original"));
+      viewport.setViewName(
+              MessageManager.getString("label.view_name_original"));
     }
 
     /*
@@ -4483,7 +4483,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             int assocfiles = 0;
             if (filesmatched.size() > 0)
             {
-              boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
+              boolean autoAssociate = Cache
+                      .getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
               if (!autoAssociate)
               {
                 String msg = MessageManager.formatMessage(
index 3ac8656..4017931 100644 (file)
@@ -48,7 +48,8 @@ public class CommandLineOperations
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
   }
 
-  private static final int TEST_TIMEOUT = 9000; // Note longer timeout needed on
+  private static final int TEST_TIMEOUT = 9000; // Note longer timeout needed
+                                                // on
                                                 // full test run than on
                                                 // individual tests
 
@@ -140,14 +141,14 @@ public class CommandLineOperations
     }
     return classpath;
   }
+
   private Worker jalviewDesktopRunner(boolean withAwt, String cmd,
           int timeout)
   {
     // Note: JAL-3065 - don't include quotes for lib/* because the arguments are
     // not expanded by the shell
     String classpath = getClassPath();
-    String _cmd = "java "
-            + (withAwt ? "-Djava.awt.headless=true" : "")
+    String _cmd = "java " + (withAwt ? "-Djava.awt.headless=true" : "")
             + " -classpath " + classpath + " jalview.bin.Jalview ";
     Process ls2_proc = null;
     Worker worker = null;
@@ -233,7 +234,8 @@ public class CommandLineOperations
   }
 
   @Test(
-    groups = { "Functional" },
+    groups =
+    { "Functional", "testben" },
     dataProvider = "headlessModeOutputOperationsData")
   public void testHeadlessModeOutputOperations(String harg, String type,
           String fileName, boolean withAWT, int expectedMinFileSize,
@@ -244,19 +246,20 @@ public class CommandLineOperations
     File file = new File(fileName);
     Worker worker = jalviewDesktopRunner(withAWT, cmd, timeout);
 
-    FileAssert.assertFile(file, "Didn't create an output" + type
-            + " file.[" + harg + "]");
-    FileAssert.assertMinLength(new File(fileName), expectedMinFileSize);
+    FileAssert.assertFile(file,
+            "Didn't create an output" + type + " file.[" + harg + "]");
+    // System.out.println( "File '" + file.getName() + "' has size " +
+    // file.length());
+    // FileAssert.assertMinLength(new File(fileName), expectedMinFileSize);
+    FileAssert.assertMinLength(file, expectedMinFileSize);
     if (worker != null && worker.exit == null)
     {
       worker.interrupt();
       Thread.currentThread().interrupt();
       worker.process.destroy();
-      Assert.fail("Jalview did not exit after "
-              + type
+      Assert.fail("Jalview did not exit after " + type
               + " generation (try running test again to verify - timeout at "
-              + SETUP_TIMEOUT + "ms). ["
-              + harg + "]");
+              + timeout + "ms). [" + harg + "]");
     }
     new File(fileName).delete();
   }
@@ -272,8 +275,7 @@ public class CommandLineOperations
             "Failed command : -props File" },
         { "CMD [-sortbytree] executed successfully!",
             "Failed command : -sortbytree" },
-        {
-            "CMD [-jabaws http://www.compbio.dundee.ac.uk/jabaws] executed successfully!",
+        { "CMD [-jabaws http://www.compbio.dundee.ac.uk/jabaws] executed successfully!",
             "Failed command : -jabaws http://www.compbio.dundee.ac.uk/jabaws" },
         { "CMD [-open examples/uniref50.fa] executed successfully!",
             "Failed command : -open examples/uniref50.fa" },
@@ -281,14 +283,11 @@ public class CommandLineOperations
             "Failed command : -nosortbytree" },
         { "CMD [-dasserver nickname=www.test.com] executed successfully!",
             "Failed command : -dasserver nickname=www.test.com" },
-        {
-            "CMD [-features examples/testdata/plantfdx.features]  executed successfully!",
+        { "CMD [-features examples/testdata/plantfdx.features]  executed successfully!",
             "Failed command : -features examples/testdata/plantfdx.features" },
-        {
-            "CMD [-annotations examples/testdata/plantfdx.annotations] executed successfully!",
+        { "CMD [-annotations examples/testdata/plantfdx.annotations] executed successfully!",
             "Failed command : -annotations examples/testdata/plantfdx.annotations" },
-        {
-            "CMD [-tree examples/testdata/uniref50_test_tree] executed successfully!",
+        { "CMD [-tree examples/testdata/uniref50_test_tree] executed successfully!",
             "Failed command : -tree examples/testdata/uniref50_test_tree" },
         // non headless mode input operations
         { "CMD [-nousagestats] executed successfully!",
@@ -319,20 +318,28 @@ public class CommandLineOperations
         { "headless -open examples/uniref50.fa", " -html",
             "test_uniref50_out.html", true, MINFILESIZE_BIG, TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -fasta",
-            "test_uniref50_out.mfa", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.mfa", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -clustal",
-            "test_uniref50_out.aln", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.aln", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -msf",
-            "test_uniref50_out.msf", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.msf", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -pileup",
-            "test_uniref50_out.aln", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.aln", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -pir",
-            "test_uniref50_out.pir", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.pir", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -pfam",
-            "test_uniref50_out.pfam", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.pfam", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -blc",
-            "test_uniref50_out.blc", true, MINFILESIZE_SMALL, TEST_TIMEOUT },
+            "test_uniref50_out.blc", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT },
         { "headless -open examples/uniref50.fa", " -jalview",
-            "test_uniref50_out.jvp", true, MINFILESIZE_SMALL, TEST_TIMEOUT }, };
+            "test_uniref50_out.jvp", true, MINFILESIZE_SMALL,
+            TEST_TIMEOUT }, };
   }
 }