public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Better handle TestRunner class.testName
@ 2008-04-30 22:47 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-04-30 22:47 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  6ffbfe68fd18e6921b5c603c20d1abfcaa2c4f89 (commit)
      from  56ff5da9054640e37a187ff37871dc6d02058a0d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 6ffbfe68fd18e6921b5c603c20d1abfcaa2c4f89
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed Apr 30 18:46:32 2008 -0400

    Better handle TestRunner class.testName
    
    frysk-sys/frysk/junit/ChangeLog
    2008-04-30  Andrew Cagney  <cagney@redhat.com>
    
    	* Runner.java: Simplify argument mathing; especially
    	class.testName.

-----------------------------------------------------------------------

Summary of changes:
 frysk-sys/frysk/junit/ChangeLog   |    5 ++
 frysk-sys/frysk/junit/Runner.java |  112 ++++++++++++++++++++----------------
 2 files changed, 67 insertions(+), 50 deletions(-)

First 500 lines of diff:
diff --git a/frysk-sys/frysk/junit/ChangeLog b/frysk-sys/frysk/junit/ChangeLog
index ef99570..dd5ddd2 100644
--- a/frysk-sys/frysk/junit/ChangeLog
+++ b/frysk-sys/frysk/junit/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-30  Andrew Cagney  <cagney@redhat.com>
+
+	* Runner.java: Simplify argument mathing; especially
+	class.testName.
+
 2008-04-17  Andrew Cagney  <cagney@redhat.com>
 
 	* TestCase.java: Use frysk.config.Prefix.
diff --git a/frysk-sys/frysk/junit/Runner.java b/frysk-sys/frysk/junit/Runner.java
index 49ade26..add01be 100755
--- a/frysk-sys/frysk/junit/Runner.java
+++ b/frysk-sys/frysk/junit/Runner.java
@@ -42,6 +42,7 @@ package frysk.junit;
 import frysk.config.FryskVersion;
 import frysk.config.Prefix;
 import frysk.config.Host;
+import frysk.rsl.Log;
 import frysk.rsl.LogOption;
 import frysk.expunit.Expect;
 import gnu.classpath.tools.getopt.FileArgumentCallback;
@@ -64,6 +65,8 @@ import junit.textui.TestRunner;
  */
 
 public class Runner extends TestRunner {
+    private static final Log fine = Log.fine(Runner.class);
+
     // Repeat once by default.
     private int repeatValue = 1;
     private Collection testCases = null;
@@ -95,61 +98,70 @@ public class Runner extends TestRunner {
       
 	TestSuite testSuite = new TestSuite ();
       
-	if (otherArgs.size() > 0) {
-	    // Construct the testsuite from the list of names.
-	    for (Iterator argIter = otherArgs.listIterator(0);
-		 argIter.hasNext(); ) {
-		String arg = (String)argIter.next();
-		if (arg.charAt(0) == '-') {
-		    this.repeatValue = - Integer.parseInt(arg);
-		} else {
-		    int lidot = arg.lastIndexOf('.');
-		    String testName = null;
-		    String testClass = null;
-		    if (arg.substring(lidot + 1).startsWith("test")) {
-			testClass = arg.substring(0, lidot);
-			testName = arg.substring(lidot + 1);
-		    } else if (arg.matches("test.*\\(.*\\)")) {
-			String[] testTuple = arg.split("[\\(\\)]");
-			testName = testTuple[0];
-			testClass = testTuple[1];
-		    } else {
-			testClass = arg;
-		    }
+	// Construct the testsuite from the list of names.
+	for (Iterator i = otherArgs.iterator(); i.hasNext(); ) {
+	    String arg = (String) i.next();
+
+	    // A -N argument specifying a repeat count.
+	    if (arg.matches("^-[0-9]*$")) {
+		repeatValue = - Integer.parseInt(arg);
+		fine.log(this, "repeat", repeatValue);
+		continue;
+	    }
+
+	    String testMethod;
+	    String testClass;
+	    if (arg.matches("^test.*\\(.*\\)$")) {
+		// testFoo(frysk.class)
+		String[] testTuple = arg.split("[\\(\\)]");
+		testMethod = testTuple[0];
+		testClass = testTuple[1];
+	    } else if (arg.matches(".*\\.test[A-Z][^.]*")) {
+		// frysk.class.testMethod
+		int lidot = arg.lastIndexOf('.');
+		testClass = arg.substring(0, lidot);
+		testMethod = arg.substring(lidot + 1);
+	    } else {
+		// frysk.class
+		testClass = arg;
+		testMethod = null;
+	    }
+	    fine.log(this, "testClass", testClass, "testMethod", testMethod);
 		    
-		    for (Iterator classIter = testClasses.iterator();
-			 classIter.hasNext (); ) {
-			Class testKlass = (Class)classIter.next ();
-			if (testName == null) {
-			    // class only
-			    if (testKlass.getName().startsWith(testClass)) {
-				testSuite.addTest(new TestSuite(testKlass));
-			    }
-			} else {
-			    // class.name or name(class)
-			    if (testKlass.getName().equals(testClass)) {
-				try {
-				    // Probe the class to see if the
-				    // method exists.
-				    testKlass.getMethod(testName, null);
-				    TestCase test = (TestCase)testKlass.newInstance();
-				    test.setName(testName);
-				    testSuite.addTest(test);
-				} catch (NoSuchMethodException e) {
-				    System.out.println("Couldn't find test method: " + testClass + "." + testName);
-				} catch (InstantiationException e) {
-				    System.out.println("Couldn't instantiate class with name: "
-						       + testClass);
-				} catch (IllegalAccessException e) {
-				    System.out.println("Couldn't access class with name: "
-						       + testClass);
-				}
-			    }
+	    for (Iterator c = testClasses.iterator(); c.hasNext (); ) {
+		Class testKlass = (Class) c.next ();
+		if (testMethod == null) {
+		    // class only
+		    if (testKlass.getName().startsWith(testClass)) {
+			testSuite.addTest(new TestSuite(testKlass));
+			fine.log(this, "adding", testKlass);
+		    }
+		} else {
+		    // class.name or name(class)
+		    if (testKlass.getName().equals(testClass)) {
+			try {
+			    // Probe the class to see if the method
+			    // exists.
+			    testKlass.getMethod(testMethod, null);
+			    TestCase test = (TestCase)testKlass.newInstance();
+			    test.setName(testMethod);
+			    testSuite.addTest(test);
+			    fine.log(this, "adding", testKlass);
+			} catch (NoSuchMethodException e) {
+			    System.out.println("Couldn't find test method: " + testClass + "." + testMethod);
+			} catch (InstantiationException e) {
+			    System.out.println("Couldn't instantiate class with name: "
+					       + testClass);
+			} catch (IllegalAccessException e) {
+			    System.out.println("Couldn't access class with name: "
+					       + testClass);
 			}
 		    }
 		}
 	    }
-	} else {
+	}
+
+	if (otherArgs.size() == 0) {
 	    for (Iterator i = testClasses.iterator (); i.hasNext (); ) {
 		Class testKlass = (Class) i.next ();
 		// Only include tests that gets by both filters.


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-30 22:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-30 22:47 [SCM] master: Better handle TestRunner class.testName cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).