<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>selenium-driver/src/com/yahoo/platform/yui/selenium/FileGenerator.java</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -10,12 +10,7 @@ package com.yahoo.platform.yui.selenium;
 
 import com.thoughtworks.selenium.DefaultSelenium;
 import com.thoughtworks.selenium.Selenium;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import com.thoughtworks.selenium.SeleniumException;
 import java.util.HashMap;
 import java.util.Properties;
 
@@ -176,6 +171,11 @@ public class SeleniumDriver {
             coverage = selenium.getEval(testCoverage);
             name = selenium.getEval(testName);
 
+        } catch (SeleniumException ex){
+
+            //probably not a valid page
+            throw new Exception(&quot;Selenium failed with message: &quot; + ex.getMessage() + &quot;. Check the test URL &quot; + url + &quot; to ensure it is valid.&quot;, ex);
+
         } catch (Exception ex){
             //TODO: What should happen here? Default file generation?
             throw ex;
@@ -184,63 +184,21 @@ public class SeleniumDriver {
                 selenium.stop();
             }
         }
+
+        //save the results
         try {
+            FileGenerator generator = new FileGenerator(properties, verbose);
             //output the reports
-            outputToFile(name, results, &quot;results&quot;, browser);
+            generator.generate(name, results, &quot;results&quot;, browser);
             if (!coverage.equals(&quot;null&quot;)){
-                outputToFile(name, coverage, &quot;coverage&quot;, browser);
+                generator.generate(name, coverage, &quot;coverage&quot;, browser);
             }
             
         } catch (Exception ex){
             //what to do?
             throw ex;
         }
-    }
-    
-    private void outputToFile(String name, String results, String type, String browser) throws Exception {
-        String dirname = properties.getProperty(type + &quot;.outputdir&quot;);
-        String filenameFormat = properties.getProperty(type + &quot;.filename&quot;);
-        
-        if (dirname == null){
-            throw new Exception(&quot;Missing '&quot; + type + &quot;.outputdir' configuration parameter.&quot;);            
-        }
-        
-        if (filenameFormat == null){
-            throw new Exception(&quot;Missing '&quot; + type + &quot;.outputdir' configuration parameter.&quot;);            
-        }
-        
-        //format filename
-        String filename = filenameFormat.replace(&quot;{browser}&quot;, browser.replace(&quot;*&quot;, &quot;&quot;)).replace(&quot;{name}&quot;, name).trim();
-        
-        int pos = filename.indexOf(&quot;{date:&quot;);
-
-        if (pos &gt; -1){
-
-            int endpos = filename.indexOf(&quot;}&quot;, pos);
-            String format = filename.substring(pos + 6, endpos);
-            
-            //get the format
-            Date now = new Date();
-            SimpleDateFormat formatter = new SimpleDateFormat(format);
-            
-            //insert into filename
-            filename = filename.replace(&quot;{date:&quot; + format + &quot;}&quot;, formatter.format(now));
-        }
-        
-        filename = filename.replaceAll(&quot;[^a-zA-Z0-9\\.\\-]&quot;, &quot;_&quot;).replaceAll(&quot;_+&quot;, &quot;_&quot;);
-        
-        if (verbose){
-            System.err.println(&quot;[INFO] Outputting &quot; + type + &quot; to &quot; + dirname + File.separator + filename);
-        }
-        
-        //output to file
-        Writer out = new OutputStreamWriter(new FileOutputStream(dirname + File.separator + filename), &quot;UTF-8&quot;);
-        out.write(results);
-        out.close();
-        
-    }
-    
-    
+    }        
     
     private void getURLsAndBrowsers() throws Exception {
         </diff>
      <filename>selenium-driver/src/com/yahoo/platform/yui/selenium/SeleniumDriver.java</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,7 @@ public class YUITestSeleniumDriver {
         CmdLineParser parser = new CmdLineParser();
         CmdLineParser.Option verboseOpt = parser.addBooleanOption('v', &quot;verbose&quot;);
         CmdLineParser.Option helpOpt = parser.addBooleanOption('h', &quot;help&quot;);
+        CmdLineParser.Option errorOnFailOpt = parser.addBooleanOption(&quot;erroronfail&quot;);
         CmdLineParser.Option confOpt = parser.addStringOption(&quot;conf&quot;);
         CmdLineParser.Option hostOpt = parser.addStringOption(&quot;host&quot;);
         CmdLineParser.Option portOpt = parser.addStringOption(&quot;port&quot;);
@@ -118,16 +119,17 @@ public class YUITestSeleniumDriver {
             usage();
             System.exit(1);
 
-        } catch (IOException e) {
+        } catch (Exception e) {
 
-            e.printStackTrace();
+            System.err.println(&quot;[ERROR] &quot; + e.getMessage());
+            //e.printStackTrace();
             System.exit(1);
 
-        } catch (Exception e) {
-
-            e.printStackTrace();
-            // Return a special error code used specifically by the web front-end.
-            System.exit(2);
+//        } catch (Exception e) {
+//
+//            e.printStackTrace();
+//            // Return a special error code used specifically by the web front-end.
+//            System.exit(2);
         
         } finally {
 
@@ -157,6 +159,8 @@ public class YUITestSeleniumDriver {
                         + &quot;  -h, --help                Displays this information.\n&quot;
                         + &quot;  --browsers &lt;browsers&gt;     Run tests in these browseres (comma-delimited).\n&quot;
                         + &quot;  --conf &lt;file&gt;             Load options from &lt;file&gt;.\n&quot;
+                        + &quot;  --erroronfail             Indicates that a test failure should cause\n&quot;
+                        + &quot;                            an error to be reported to the console.\n&quot;
                         + &quot;  --host &lt;host&gt;             Use the Selenium host &lt;host&gt;.\n&quot;
                         + &quot;  --port &lt;port&gt;             Use &lt;port&gt; port on the Selenium host.\n&quot;
                         + &quot;  --yuitest &lt;version&gt;       The version of YUI Test to use (2 or 3).\n&quot;</diff>
      <filename>selenium-driver/src/com/yahoo/platform/yui/selenium/YUITestSeleniumDriver.java</filename>
    </modified>
    <modified>
      <diff>@@ -17,8 +17,9 @@ results.outputdir = .
 coverage.outputdir = .
 
 #Filename format
-#There are two variables:
-# 1. {browser} to insert the browser name
-# 2.{date:&lt;format&gt;}, where &lt;format&gt; is a SimpleDateFormat (http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html)
+#There are some variables:
+# 1.{browser} to insert the browser name
+# 2.{name} to insert the name of the test (specified by TestRunner.setName() in JavaScript)
+# 3.{date:&lt;format&gt;}, where &lt;format&gt; is a SimpleDateFormat (http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html)
 results.filename = test-{browser}-{name}-{date:yyyyMMddHHmmss}.xml
 coverage.filename = coverage-{browser}-{name}-{date:yyyyMMddHHmmss}.json</diff>
      <filename>selenium-driver/src/com/yahoo/platform/yui/selenium/default.properties</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a955382db28f225a020035ad685dfe96c792fbaa</id>
    </parent>
  </parents>
  <author>
    <name>Nicholas</name>
    <email>nzakas@yahoo-inc.com</email>
  </author>
  <url>http://github.com/nzakas/yuitest/commit/789d542c85849c80df4fd42f0812edc8dc25da56</url>
  <id>789d542c85849c80df4fd42f0812edc8dc25da56</id>
  <committed-date>2009-11-06T12:30:22-08:00</committed-date>
  <authored-date>2009-11-06T12:30:22-08:00</authored-date>
  <message>Better error handling/reporting</message>
  <tree>39055e881fde95a8f7db99fa147e005afe86cf92</tree>
  <committer>
    <name>Nicholas</name>
    <email>nzakas@yahoo-inc.com</email>
  </committer>
</commit>
