omit tests if no ships of that type present
authoradam <adam@megacz.com>
Sat, 8 Nov 2008 06:05:19 +0000 (07:05 +0100)
committeradam <adam@megacz.com>
Sat, 8 Nov 2008 06:05:19 +0000 (07:05 +0100)
src/edu/berkeley/fleet/Main.java
src/edu/berkeley/fleet/two/ShipDescription.java

index e1eaed0..b259d3e 100644 (file)
@@ -155,10 +155,12 @@ public class Main {
         } else if (f.getPath().endsWith(".ship")) {
             ShipDescription sd = new ShipDescription(f.getName(), new BufferedReader(new InputStreamReader(new FileInputStream(f))));
             String testsection = sd.getSection("test");
-            if (testsection != null)
-                runTest(fleet, new StringReader(testsection), sd.getName());
-            else
+            if (testsection == null)
                 System.out.println("no test for " + sd.getName() + "!");
+            else if (fleet.getShip(sd.getName(),0)==null)
+                System.out.println("specified Fleet does not have any ships of type " + sd.getName());
+            else
+                runTest(fleet, new StringReader(testsection), sd.getName());
         }
     }
 
index 159442c..dcf0a97 100644 (file)
@@ -17,6 +17,7 @@ public class ShipDescription implements Iterable<DockDescription> {
     public Iterator<DockDescription> iterator() { return docks.values().iterator(); }
 
     public ShipDescription(String name, BufferedReader r) throws IOException {
+        if (name.endsWith(".ship")) name = name.substring(0, name.length()-".ship".length());
         this.name = name;
         String sectionName = null;
         StringBuffer sb = new StringBuffer();