public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Allow << ./TestRunner frysk.config >>
@ 2008-04-17  1:28 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-04-17  1:28 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  0ed6ec301f2086eaf9f88b8f16a7f36191616875 (commit)
      from  85a1a3630fbe5c7ce5f5f2dfd9d1b01f6d32f2cb (commit)

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

- Log -----------------------------------------------------------------
commit 0ed6ec301f2086eaf9f88b8f16a7f36191616875
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed Apr 16 21:24:25 2008 -0400

    Allow << ./TestRunner frysk.config >>
    
    frysk-sys/frysk/junit/ChangeLog
    2008-04-16  Andrew Cagney  <cagney@redhat.com>
    
    	* Runner.java: Match partial class names.

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

Summary of changes:
 frysk-sys/frysk/junit/ChangeLog   |    4 ++
 frysk-sys/frysk/junit/Runner.java |   74 +++++++++++++++++++-----------------
 2 files changed, 43 insertions(+), 35 deletions(-)

First 500 lines of diff:
diff --git a/frysk-sys/frysk/junit/ChangeLog b/frysk-sys/frysk/junit/ChangeLog
index 11f1a89..f382888 100644
--- a/frysk-sys/frysk/junit/ChangeLog
+++ b/frysk-sys/frysk/junit/ChangeLog
@@ -1,3 +1,7 @@
+2008-04-16  Andrew Cagney  <cagney@redhat.com>
+
+	* Runner.java: Match partial class names.
+
 2008-04-15  Andrew Cagney  <cagney@redhat.com>
 
 	* Runner.java: Use Prefix and PrefixFactory.
diff --git a/frysk-sys/frysk/junit/Runner.java b/frysk-sys/frysk/junit/Runner.java
index 96023d6..49ade26 100755
--- a/frysk-sys/frysk/junit/Runner.java
+++ b/frysk-sys/frysk/junit/Runner.java
@@ -97,63 +97,67 @@ public class Runner extends TestRunner {
       
 	if (otherArgs.size() > 0) {
 	    // Construct the testsuite from the list of names.
-	    Iterator iter = otherArgs.listIterator(0);
-	    while (iter.hasNext()) {
-		String arg = (String) iter.next();
+	    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 testCaseName = null;
+		    String testClass = null;
 		    if (arg.substring(lidot + 1).startsWith("test")) {
-			testCaseName = arg.substring(0, lidot);
+			testClass = arg.substring(0, lidot);
 			testName = arg.substring(lidot + 1);
 		    } else if (arg.matches("test.*\\(.*\\)")) {
 			String[] testTuple = arg.split("[\\(\\)]");
 			testName = testTuple[0];
-			testCaseName = testTuple[1];
+			testClass = testTuple[1];
 		    } else {
-			testCaseName = arg;
+			testClass = arg;
 		    }
 		    
-		    try {
+		    for (Iterator classIter = testClasses.iterator();
+			 classIter.hasNext (); ) {
+			Class testKlass = (Class)classIter.next ();
 			if (testName == null) {
-			    testSuite.addTest(getTest(testCaseName));
+			    // class only
+			    if (testKlass.getName().startsWith(testClass)) {
+				testSuite.addTest(new TestSuite(testKlass));
+			    }
 			} else {
-			    Class klass = loadSuiteClass(testCaseName);
-			    TestCase test = (TestCase) klass.newInstance();
-			    
-			    //Check if the method exists.
-			    klass.getMethod(testName, null);
-			    
-			    test.setName(testName);
-			    testSuite.addTest(test);
+			    // 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);
+				}
+			    }
 			}
-		    } catch (NoSuchMethodException e) {
-			System.out.println("Couldn't find method with name: "
-					   + testName);
-		    } catch (ClassNotFoundException e) {
-			System.out.println("Couldn't find class with name: "
-					   + testCaseName);
-		    } catch (InstantiationException e) {
-			System.out.println("Couldn't instantiate class with name: "
-					   + testCaseName);
-		    } catch (IllegalAccessException e) {
-			System.out.println("Couldn't access class with name: "
-					   + testCaseName);
 		    }
 		}
 	    }
 	} else {
 	    for (Iterator i = testClasses.iterator (); i.hasNext (); ) {
-		Class testClass = (Class) i.next ();
+		Class testKlass = (Class) i.next ();
 		// Only include tests that gets by both filters.
-		if (testClass.getName ().matches (testFilter)) {
+		if (testKlass.getName ().matches (testFilter)) {
 		    boolean addit = true;
 		    for (int j = 0; j < excludeTests.size(); j++) {
 			try {
-			    if (testClass.getName ()
+			    if (testKlass.getName ()
 				.matches ((String)excludeTests.get (j))) {
 				addit = false;
 				break;
@@ -165,7 +169,7 @@ public class Runner extends TestRunner {
 		    if (!addit) {
 			for (int j = 0; j < includeTests.size(); j++) {
 			    try {
-				if (testClass.getName ()
+				if (testKlass.getName ()
 				    .matches ((String)includeTests.get (j))) {
 				    addit = true;
 				    break;
@@ -176,9 +180,9 @@ public class Runner extends TestRunner {
 			}
 		    }
 		    if (addit) {
-			testSuite.addTest (new TestSuite (testClass));
+			testSuite.addTest (new TestSuite (testKlass));
 		    } else {
-			System.out.println ("Omitting " + testClass.getName());
+			System.out.println ("Omitting " + testKlass.getName());
 		    }
 		}
 	    }


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


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

only message in thread, other threads:[~2008-04-17  1:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-17  1:28 [SCM] master: Allow << ./TestRunner frysk.config >> 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).