From c2326dd4649b1b8ba1a71fcb977d871c8e7c9d3e Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sun, 20 Sep 2009 12:34:32 -0700 Subject: [PATCH] FleetProcess.java: add masterClear() method, use it in Main.java --- src/edu/berkeley/fleet/Main.java | 28 +++++++++++++++----------- src/edu/berkeley/fleet/api/FleetProcess.java | 2 ++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/edu/berkeley/fleet/Main.java b/src/edu/berkeley/fleet/Main.java index 885e0c1..aee832d 100644 --- a/src/edu/berkeley/fleet/Main.java +++ b/src/edu/berkeley/fleet/Main.java @@ -70,15 +70,20 @@ public class Main { pw.close(); } else if (command.equals("test")) { - for(int i=0; i expect = edu.berkeley.fleet.assembler.Parser.expect; String output = ""; // FIXME: check for extraneous stuff at the end @@ -132,18 +139,15 @@ public class Main { } } System.out.println(); - } finally { - fp.terminate(); - } } - static void test(Fleet fleet, File f) throws Exception { + static void test(Fleet fleet, FleetProcess fp, File f) throws Exception { if (f.isDirectory()) { for(String s : f.list()) - test(fleet, new File(f.getPath() + File.separatorChar + s)); + test(fleet, fp, new File(f.getPath() + File.separatorChar + s)); return; } else if (f.getPath().endsWith(".fleet") || f.getPath().endsWith(".test")) { - runTest(fleet, new InputStreamReader(new FileInputStream(f)), f.getPath()); + runTest(fleet, fp, new InputStreamReader(new FileInputStream(f)), f.getPath()); } else if (f.getPath().endsWith(".ship")) { ShipDescription sd = new ShipDescription(fleet, f.getName(), new BufferedReader(new InputStreamReader(new FileInputStream(f)))); String testsection = sd.getSection("test"); @@ -152,7 +156,7 @@ public class Main { else if (fleet.getShip(sd.getName(),0)==null && !(fleet instanceof edu.berkeley.fleet.assembler.Parser.FleetWithDynamicShips)) System.out.println("specified Fleet does not have any ships of type " + sd.getName()); else - runTest(fleet, new StringReader(testsection), sd.getName()); + runTest(fleet, fp, new StringReader(testsection), sd.getName()); } } diff --git a/src/edu/berkeley/fleet/api/FleetProcess.java b/src/edu/berkeley/fleet/api/FleetProcess.java index c232405..2dd7332 100644 --- a/src/edu/berkeley/fleet/api/FleetProcess.java +++ b/src/edu/berkeley/fleet/api/FleetProcess.java @@ -50,6 +50,8 @@ public abstract class FleetProcess { /** Terminate the process; subclasses may be assured that this will be called exactly once. */ protected abstract void _terminate(); + public void masterClear() { throw new RuntimeException("not implemented"); } + /** Terminate the process. */ public final synchronized void terminate() { if (terminated) return; -- 1.7.10.4