curcuru     00/12/27 13:12:24

  Modified:    test/java/src/org/apache/qetest/xsl
                        XSLProcessorTestBase.java
  Log:
  Various updates to createStatusFile(); this method needs
  to be revisited to better match how the rest of the framework works
  
  Revision  Changes    Path
  1.7       +57 -22    
xml-xalan/test/java/src/org/apache/qetest/xsl/XSLProcessorTestBase.java
  
  Index: XSLProcessorTestBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XSLProcessorTestBase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSLProcessorTestBase.java 2000/12/23 22:54:07     1.6
  +++ XSLProcessorTestBase.java 2000/12/27 21:12:23     1.7
  @@ -91,7 +91,7 @@
    * <li>runErr</li>
    * </ul>
    * @author [EMAIL PROTECTED]
  - * @version $Id: XSLProcessorTestBase.java,v 1.6 2000/12/23 22:54:07 sboag 
Exp $
  + * @version $Id: XSLProcessorTestBase.java,v 1.7 2000/12/27 21:12:23 curcuru 
Exp $
    */
   public class XSLProcessorTestBase extends FileBasedTest
   {
  @@ -730,34 +730,66 @@
       /**
        * Write a "{TestName}.Pass" or "{TestName}.Not.Pass" file 
        * according to whether or not the overall test passed.
  +     * But: Don't write this file if we're a Minitest, since 
  +     * Minitests already output a better format of a status 
  +     * file already in doTestFileClose (which is where this 
  +     * kind of functionality probably belongs anyway).
  +     * -- Subject to change! --
  +     * @author [EMAIL PROTECTED]
        */
       protected void createStatusFile()
       {
  -      System.out.println("reporter: "+reporter);
  -      if(null != reporter)
  -      {
  -        String testName = this.getTestName();
  -        File resultsFile = new File(testProps.getProperty("logFile"));
  -        File passfile = new File(resultsFile.getParent(), testName+".Pass");
  -        File failfile = new File(resultsFile.getParent(), 
testName+".Not.Pass");
  -        if(passfile.exists())
  -          passfile.delete();
  -        if(failfile.exists())
  -          failfile.delete();
  -        
  -        File statusfile = reporter.didPass() ? passfile : failfile;          
       
  -        try
  +        if(null != reporter)
           {
  -          java.io.FileOutputStream fio = new 
java.io.FileOutputStream(statusfile);
  -          fio.write(0);
  -          fio.close();
  +            String testName = this.getTestName();
  +            if ("Minitest".equalsIgnoreCase(testName))
  +            {
  +                reporter.logWarningMsg("Note! Minitests write their own 
status files!");
  +                return;                
  +            }
  +            File resultsFile = new File(testProps.getProperty("logFile"));
  +            // Note we can either have pass/notpass, or we can 
  +            //  use the full set of test status values from 
  +            //  Logger.java: pass/fail/errr/incp/ambg
  +            File passfile = new File(resultsFile.getParent(), testName + "." 
+ Logger.PASS);
  +            File failfile = new File(resultsFile.getParent(), testName + 
".Not." + Logger.PASS);
  +            if(passfile.exists())
  +                passfile.delete();
  +            if(failfile.exists())
  +                failfile.delete();
  +
  +            // didPass returns pass/fail in a different manner 
  +            //  than is used elsewhere in the tests.  We need to 
  +            //  decide on a common way to do this everywhere.
  +            //  See Logger's javadoc for PASS_RESULT, INCP_RESULT, etc.
  +            // the only potential difficulty (for minitest, etc. use)
  +            //  is ambiguous results, which are neither passes 
  +            //  nor fails
  +            // File statusfile = reporter.didPass() ? passfile : failfile;   
              
  +            File statusfile = null;
  +            if (reporter.getCurrentFileResult() == Logger.PASS_RESULT)
  +                statusfile = passfile;
  +            else
  +                statusfile = failfile;
  +
  +            try
  +            {
  +                java.io.FileOutputStream fio = new 
java.io.FileOutputStream(statusfile);
  +                fio.write(0);   // We should really write something more 
meaningful here
  +                fio.close();
  +            }
  +            catch(Exception e)
  +            {
  +                // Note: System.out/.err should *only* *ever* be 
  +                //  used in places where a reporter is not available
  +                // System.out.println("Can't write: "+statusfile.toString());
  +                reporter.logCriticalMsg("Can't write: " + 
statusfile.toString());
  +            }
           }
  -        catch(Exception e)
  +        else
           {
  -          System.out.println("Can't write: "+statusfile.toString());
  +            System.err.println("ERROR! createStatusFile has no reporter, 
can't work!");
           }
  -      }
  -
       }
   
       /**
  @@ -798,6 +830,9 @@
           testProps.put(MAIN_CMDLINE, args);
           runTest(testProps);
           
  +        // Note that this is only called if run from the command
  +        //  line directly, and is not called when executed from 
  +        //  XSLTestHarness (which calls runTest directly)
           createStatusFile();
       }
   
  
  
  

Reply via email to