pw.close();
} else if (command.equals("test")) {
- for(int i=0; i<args.size(); i++)
- test(fleet, new File(args.get(i)));
+ FleetProcess fp = fleet.run(null);
+ try {
+ for(int i=0; i<args.size(); i++)
+ test(fleet, fp, new File(args.get(i)));
+ } finally {
+ fp.terminate();
+ }
} else {
usage();
System.exit(-1);
}
}
- static void runTest(Fleet fleet, Reader reader, String title) throws Exception {
+ static void runTest(Fleet fleet, FleetProcess fp, Reader reader, String title) throws Exception {
Instruction[] instructions = null;
System.out.print("\r[ ] " + ANSI.yellow(title)+": ");
try {
edu.berkeley.fleet.assembler.Parser.skip = false;
return;
}
- FleetProcess fp = fleet.run(instructions);
+ fp.masterClear();
+ for(Instruction i : instructions)
+ fp.sendInstruction(i);
//long now = System.currentTimeMillis();
- try {
+
ArrayList<Long> expect = edu.berkeley.fleet.assembler.Parser.expect;
String output = "";
// FIXME: check for extraneous stuff at the end
}
}
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");
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());
}
}