public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: expunit.EofException -> EndOfFileException; expand exception messages.
@ 2007-12-15  1:08 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2007-12-15  1:08 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  523f56213ae2f667cce2af311f7a837c2e22188b (commit)
      from  9bbfe5c000a1fc3116d8eb919d1ebd061ebbf1f4 (commit)

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

- Log -----------------------------------------------------------------
commit 523f56213ae2f667cce2af311f7a837c2e22188b
Author: Andrew Cagney <cagney@redhat.com>
Date:   Fri Dec 14 20:07:35 2007 -0500

    expunit.EofException -> EndOfFileException; expand exception messages.
    
    frysk-core/frysk/hpd/ChangeLog
    2007-12-14  cagney  <cagney@redhat.com>
    
    	* HpdTestbed.java: Update; EofException renamed to EndOfFileException.
    	* TestPreprocessor.java: Ditto.
    
    frysk-sys/frysk/expunit/ChangeLog
    2007-12-14  cagney  <cagney@redhat.com>
    
    	* EndOfFileException.java: Rename EofException.java.
    	(EndOfFileException(Match[], String)): Replace EndOfFileException().
    	* TimeoutException.java (TimeoutException(long, Match[], String)): Replace TimeoutException(long).
    	* Expect.java: Update.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                     |    5 ++
 frysk-core/frysk/hpd/HpdTestbed.java               |    8 ++--
 frysk-core/frysk/hpd/TestPreprocessor.java         |    4 +-
 frysk-sys/frysk/expunit/ChangeLog                  |    8 +++
 ...ationException.java => EndOfFileException.java} |   31 +++++++----
 frysk-sys/frysk/expunit/EofException.java          |   54 --------------------
 frysk-sys/frysk/expunit/Expect.java                |    9 ++--
 frysk-sys/frysk/expunit/TimeoutException.java      |   22 +++++++-
 8 files changed, 63 insertions(+), 78 deletions(-)
 copy frysk-sys/frysk/expunit/{TerminationException.java => EndOfFileException.java} (79%)
 delete mode 100644 frysk-sys/frysk/expunit/EofException.java

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index cae4d71..c8afbd5 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-14  cagney  <cagney@redhat.com>
+
+	* HpdTestbed.java: Update; EofException renamed to EndOfFileException.
+	* TestPreprocessor.java: Ditto.
+
 2007-12-13  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	Moved frysk.rt.Line to frysk.scopes.SourceLocation.
diff --git a/frysk-core/frysk/hpd/HpdTestbed.java b/frysk-core/frysk/hpd/HpdTestbed.java
index 9914ee5..2cec313 100644
--- a/frysk-core/frysk/hpd/HpdTestbed.java
+++ b/frysk-core/frysk/hpd/HpdTestbed.java
@@ -45,7 +45,7 @@ import frysk.testbed.CoreFileAtSignal;
 import frysk.expunit.Expect;
 import frysk.expunit.Match;
 import frysk.expunit.Regex;
-import frysk.expunit.EofException;
+import frysk.expunit.EndOfFileException;
 import frysk.expunit.TimeoutException;
 import java.io.File;
 import frysk.testbed.TearDownExpect;
@@ -105,7 +105,7 @@ public class HpdTestbed
 			   }
 		       }
 		   });
-	} catch (EofException e) {
+	} catch (EndOfFileException e) {
 	    TestCase.fail(why + " got: <EOF>");
 	} catch (TimeoutException t) {
 	    TestCase.fail(why + " got: <TIMEOUT>");
@@ -119,7 +119,7 @@ public class HpdTestbed
     public HpdTestbed expectPrompt() {
 	try {
 	    expect(prompt);
-	} catch (EofException e) {
+	} catch (EndOfFileException e) {
 	    TestCase.fail("expecting: <" + prompt + "> got: EOF");
 	} catch (TimeoutException t) {
 	    TestCase.fail("expecting: <" + prompt + "> got: TIMEOUT");
@@ -197,7 +197,7 @@ public class HpdTestbed
 			     }
 			 }
 		     });
-	} catch (EofException e) {
+	} catch (EndOfFileException e) {
 	    TestCase.fail("Expecting <run " + program + "> got: <EOF>");
 	} catch (TimeoutException t) {
 	    TestCase.fail("Expecting <run " + program + "> got: <TIMEOUT>");
diff --git a/frysk-core/frysk/hpd/TestPreprocessor.java b/frysk-core/frysk/hpd/TestPreprocessor.java
index 84e4ffd..000d643 100644
--- a/frysk-core/frysk/hpd/TestPreprocessor.java
+++ b/frysk-core/frysk/hpd/TestPreprocessor.java
@@ -40,7 +40,7 @@
 package frysk.hpd;
 
 import frysk.expunit.Regex;
-import frysk.expunit.EofException;
+import frysk.expunit.EndOfFileException;
 
 /**
  * Test the pre-processor which unpacks stuff like
@@ -68,7 +68,7 @@ public class TestPreprocessor extends TestLib {
 			fail("Unexpected input: <<" + group() + ">>");
 		    }
 		});
-	} catch (EofException e) {
+	} catch (EndOfFileException e) {
 	    eof = true;
 	}
 	assertTrue("eof", eof);
diff --git a/frysk-sys/frysk/expunit/ChangeLog b/frysk-sys/frysk/expunit/ChangeLog
index 16d4b15..1173518 100644
--- a/frysk-sys/frysk/expunit/ChangeLog
+++ b/frysk-sys/frysk/expunit/ChangeLog
@@ -1,3 +1,11 @@
+2007-12-14  cagney  <cagney@redhat.com>
+
+	* EndOfFileException.java: Rename EofException.java.
+	(EndOfFileException(Match[], String)): Replace EndOfFileException().
+	* TimeoutException.java (TimeoutException(long, Match[], String)): Replace TimeoutException(long).
+	* Expect.java: Update.
+	
+
 2007-12-04  Andrew Cagney  <cagney@redhat.com>
 
 	Merged frysk.sys.Sig into frysk.sys.Signal.
diff --git a/frysk-sys/frysk/expunit/TerminationException.java b/frysk-sys/frysk/expunit/EndOfFileException.java
similarity index 79%
copy from frysk-sys/frysk/expunit/TerminationException.java
copy to frysk-sys/frysk/expunit/EndOfFileException.java
index 7c69c9f..e815132 100644
--- a/frysk-sys/frysk/expunit/TerminationException.java
+++ b/frysk-sys/frysk/expunit/EndOfFileException.java
@@ -43,19 +43,26 @@ package frysk.expunit;
  * Thrown an an end-of-file is encountered and nothing else matches.
  */
 
-public class TerminationException
-    extends RuntimeException
-{
+public class EndOfFileException extends RuntimeException {
     static final long serialVersionUID = 1;
-    static private String expecting (int expectedStatus)
-    {
-	if (expectedStatus >= 0)
-	    return " (expecting exit with status " + expectedStatus + ")";
-	else
-	    return " (expecting kill with signal " + expectedStatus + ")";
+
+    private static String message(Match[] matches, String output) {
+	StringBuffer msg = new StringBuffer();
+	msg.append("End-of-file");
+	if (matches != null) {
+	    msg.append("; expecting: ");
+	    for (int i = 0; i < matches.length; i++) {
+		msg.append(" <<");
+		msg.append(matches.toString());
+		msg.append(">>");
+	    }
+	}
+	msg.append("; buffer <<");
+	msg.append(output);
+	msg.append(">>");
+	return msg.toString();
     }
-    TerminationException (int expectedStatus, String s)
-    {
-	super (s + expecting (expectedStatus));
+    EndOfFileException(Match[] matches, String output) {
+	super(message(matches, output));
     }
 }
diff --git a/frysk-sys/frysk/expunit/EofException.java b/frysk-sys/frysk/expunit/EofException.java
deleted file mode 100644
index 19ec3fd..0000000
--- a/frysk-sys/frysk/expunit/EofException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2007, Red Hat Inc.
-//
-// FRYSK is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-package frysk.expunit;
-
-/**
- * Thrown an an end-of-file is encountered and nothing else matches.
- */
-
-public class EofException
-    extends RuntimeException
-{
-    static final long serialVersionUID = 1;
-    EofException ()
-    {
-	super ("End-of-file encountered");
-    }
-}
diff --git a/frysk-sys/frysk/expunit/Expect.java b/frysk-sys/frysk/expunit/Expect.java
index 83eecd0..c39918f 100644
--- a/frysk-sys/frysk/expunit/Expect.java
+++ b/frysk-sys/frysk/expunit/Expect.java
@@ -232,12 +232,13 @@ public class Expect
 	    }
 	    if (eof) {
 		logger.log (Level.FINE, "{0} match EOF\n", this);
-		throw new EofException ();
+		throw new EndOfFileException(matches, output);
 	    }
 	    long timeRemaining = endTime - System.currentTimeMillis ();
 	    if (timeRemaining <= 0) {
 		logger.log (Level.FINE, "{0} match TIMEOUT\n", this);
-		throw new TimeoutException (timeoutMilliseconds / 1000);
+		throw new TimeoutException(timeoutMilliseconds / 1000,
+			matches, output);
 	    }
 
 	    logger.log (Level.FINE,
@@ -351,7 +352,7 @@ public class Expect
 	try {
 	    expect ();
 	}
-	catch (EofException e) {
+	catch (EndOfFileException e) {
 	    // Just what the doctor ordered.
 	}
     }
@@ -366,7 +367,7 @@ public class Expect
 	try {
 	    expect ();
 	}
-	catch (EofException e) {
+	catch (EndOfFileException e) {
 	    // This is blocking; which probably isn't good.
 	    pid.blockingWait (new WaitObserver (status));
 	}
diff --git a/frysk-sys/frysk/expunit/TimeoutException.java b/frysk-sys/frysk/expunit/TimeoutException.java
index c916760..4f64398 100644
--- a/frysk-sys/frysk/expunit/TimeoutException.java
+++ b/frysk-sys/frysk/expunit/TimeoutException.java
@@ -48,8 +48,26 @@ public class TimeoutException
     extends RuntimeException
 {
     static final long serialVersionUID = 1;
-    TimeoutException (long millisecondTimeout)
+    private static String message(long millisecondTimeout, Match[] matches, String output) {
+	StringBuffer msg = new StringBuffer();
+	msg.append("Timeout of " + millisecondTimeout + " expired");
+	if (matches != null) {
+	    msg.append("; expecting: ");
+	    for (int i = 0; i < matches.length; i++) {
+		msg.append(" <<");
+		msg.append(matches.toString());
+		msg.append(">>");
+	    }
+	}
+	msg.append("; buffer <<");
+	msg.append(output);
+	msg.append(">>");
+	return msg.toString();
+    }
+
+    TimeoutException (long millisecondTimeout, Match[] matches, String output)
     {
-	super ("Timeout of " + millisecondTimeout + " expired");
+	super (message(millisecondTimeout, matches, output));
+	
     }
 }


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


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

only message in thread, other threads:[~2007-12-15  1:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-15  1:08 [SCM] master: expunit.EofException -> EndOfFileException; expand exception messages 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).