ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java JUnitTestRunner.java
Date Fri, 31 Jan 2003 07:57:42 GMT
conor       2003/01/30 23:57:42

  Modified:    src/main/org/apache/tools/ant DemuxOutputStream.java
                        Project.java Task.java UnknownElement.java
               src/main/org/apache/tools/ant/taskdefs Ant.java
                        CallTarget.java Java.java
               src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java JUnitTestRunner.java
  Log:
  Much better solution to unterminated output - better backward compat
  
  Revision  Changes    Path
  1.12      +6 -5      jakarta-ant/src/main/org/apache/tools/ant/DemuxOutputStream.java
  
  Index: DemuxOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/DemuxOutputStream.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -w -u -r1.11 -r1.12
  --- DemuxOutputStream.java	30 Jan 2003 15:12:52 -0000	1.11
  +++ DemuxOutputStream.java	31 Jan 2003 07:57:41 -0000	1.12
  @@ -191,7 +191,9 @@
        * @see Project#demuxOutput(String,boolean)
        */
       protected void processBuffer(ByteArrayOutputStream buffer) {
  -        processBuffer(buffer, true);
  +        String output = buffer.toString();
  +        project.demuxOutput(output, isErrorStream);
  +        resetBufferInfo();
       }
   
       /**
  @@ -202,10 +204,9 @@
        * 
        * @see Project#demuxOutput(String,boolean)
        */
  -    protected void processBuffer(ByteArrayOutputStream buffer, 
  -                                 boolean terminated) {
  +    protected void processFlush(ByteArrayOutputStream buffer) {
           String output = buffer.toString();
  -        project.demuxOutput(output, isErrorStream, terminated);
  +        project.demuxFlush(output, isErrorStream);
           resetBufferInfo();
       }
   
  @@ -230,7 +231,7 @@
       public void flush() throws IOException {
           BufferInfo bufferInfo = getBufferInfo();
           if (bufferInfo.buffer.size() > 0) {
  -            processBuffer(bufferInfo.buffer, false);
  +            processFlush(bufferInfo.buffer);
           }
       }
   }
  
  
  
  1.127     +17 -6     jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -w -u -r1.126 -r1.127
  --- Project.java	30 Jan 2003 15:12:52 -0000	1.126
  +++ Project.java	31 Jan 2003 07:57:41 -0000	1.127
  @@ -1228,29 +1228,40 @@
        *        or information (<code>false</code>).
        */
       public void demuxOutput(String line, boolean isError) {
  -        demuxOutput(line, isError, true);
  +        Task task = (Task) threadTasks.get(Thread.currentThread());
  +        if (task == null) {
  +            fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO);
  +        } else {
  +            if (isError) {
  +                task.handleErrorOutput(line);
  +            } else {
  +                task.handleOutput(line);
  +            }
  +        }
       }
   
       /**
  -     * Demultiplexes output so that each task receives the appropriate
  +     * Demultiplexes flush operation so that each task receives the appropriate
        * messages. If the current thread is not currently executing a task,
        * the message is logged directly.
        *
  +     * @since Ant 1.5.2
  +     *
        * @param line Message to handle. Should not be <code>null</code>.
        * @param isError Whether the text represents an error (<code>true</code>)
        *        or information (<code>false</code>).
        * @param terminated true if this line should be terminated with an 
        *        end-of-line marker
        */
  -    public void demuxOutput(String line, boolean isError, boolean terminated) {
  +    public void demuxFlush(String line, boolean isError) {
           Task task = (Task) threadTasks.get(Thread.currentThread());
           if (task == null) {
               fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO);
           } else {
               if (isError) {
  -                task.handleErrorOutput(line, terminated);
  +                task.handleErrorFlush(line);
               } else {
  -                task.handleOutput(line, terminated);
  +                task.handleFlush(line);
               }
           }
       }
  
  
  
  1.38      +10 -10    jakarta-ant/src/main/org/apache/tools/ant/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Task.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -w -u -r1.37 -r1.38
  --- Task.java	30 Jan 2003 15:12:52 -0000	1.37
  +++ Task.java	31 Jan 2003 07:57:41 -0000	1.38
  @@ -298,18 +298,18 @@
        * @param line The line of output to log. Should not be <code>null</code>.
        */
       protected void handleOutput(String line) {
  -        handleOutput(line + "X7", true);
  +        log(line, Project.MSG_INFO);
       }
   
       /**
        * Handles a line of output by logging it with the INFO priority.
        *
        * @param line The line of output to log. Should not be <code>null</code>.
  -     * @param terminated true if this line should be terminated with an 
  -     *        end-of-line marker
  +     *
  +     * @since Ant 1.5.2
        */
  -    protected void handleOutput(String line, boolean terminated) {
  -        log(line, Project.MSG_INFO);
  +    protected void handleFlush(String line) {
  +        handleOutput(line);
       }
   
       /**
  @@ -318,18 +318,18 @@
        * @param line The error line to log. Should not be <code>null</code>.
        */
       protected void handleErrorOutput(String line) {
  -        handleErrorOutput(line, true);
  +        log(line, Project.MSG_ERR);
       }
   
       /**
        * Handles an error line by logging it with the INFO priority.
        *
        * @param line The error line to log. Should not be <code>null</code>.
  -     * @param terminated true if this line should be terminated with an 
  -     *        end-of-line marker
  +     *
  +     * @since Ant 1.5.2
        */
  -    protected void handleErrorOutput(String line, boolean terminated) {
  -        log(line, Project.MSG_ERR);
  +    protected void handleErrorFlush(String line) {
  +        handleErrorOutput(line);
       }
   
       /**
  
  
  
  1.36      +6 -6      jakarta-ant/src/main/org/apache/tools/ant/UnknownElement.java
  
  Index: UnknownElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/UnknownElement.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -w -u -r1.35 -r1.36
  --- UnknownElement.java	30 Jan 2003 15:12:52 -0000	1.35
  +++ UnknownElement.java	31 Jan 2003 07:57:41 -0000	1.36
  @@ -161,11 +161,11 @@
        *
        * @param line The line of output to log. Should not be <code>null</code>.
        */
  -    protected void handleOutput(String line, boolean terminated) {
  +    protected void handleFlush(String line) {
           if (realThing instanceof Task) {
  -            ((Task) realThing).handleOutput(line, terminated);
  +            ((Task) realThing).handleFlush(line);
           } else {
  -            super.handleOutput(line, terminated);
  +            super.handleFlush(line);
           }
       }
   
  @@ -188,11 +188,11 @@
        *
        * @param line The error line to log. Should not be <code>null</code>.
        */
  -    protected void handleErrorOutput(String line, boolean terminated) {
  +    protected void handleErrorFlush(String line) {
           if (realThing instanceof Task) {
  -            ((Task) realThing).handleErrorOutput(line, terminated);
  +            ((Task) realThing).handleErrorOutput(line);
           } else {
  -            super.handleErrorOutput(line, terminated);
  +            super.handleErrorOutput(line);
           }
       }
       
  
  
  
  1.72      +10 -10    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -w -u -r1.71 -r1.72
  --- Ant.java	30 Jan 2003 15:12:52 -0000	1.71
  +++ Ant.java	31 Jan 2003 07:57:41 -0000	1.72
  @@ -288,7 +288,7 @@
        *
        * @since Ant 1.5
        */
  -    protected void handleOutput(String line) {
  +    public void handleOutput(String line) {
           if (newProject != null) {
               newProject.demuxOutput(line, false);
           } else {
  @@ -299,13 +299,13 @@
       /**
        * Pass output sent to System.out to the new project.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleOutput(String line, boolean terminated) {
  +    public void handleFlush(String line) {
           if (newProject != null) {
  -            newProject.demuxOutput(line, false, terminated);
  +            newProject.demuxFlush(line, false);
           } else {
  -            super.handleOutput(line, terminated);
  +            super.handleFlush(line);
           }
       }
   
  @@ -314,7 +314,7 @@
        *
        * @since Ant 1.5
        */
  -    protected void handleErrorOutput(String line) {
  +    public void handleErrorOutput(String line) {
           if (newProject != null) {
               newProject.demuxOutput(line, true);
           } else {
  @@ -325,13 +325,13 @@
       /**
        * Pass output sent to System.err to the new project.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleErrorOutput(String line, boolean terminated) {
  +    public void handleErrorFlush(String line) {
           if (newProject != null) {
  -            newProject.demuxOutput(line, true, terminated);
  +            newProject.demuxFlush(line, true);
           } else {
  -            super.handleErrorOutput(line, terminated);
  +            super.handleErrorFlush(line);
           }
       }
   
  
  
  
  1.28      +8 -8      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/CallTarget.java
  
  Index: CallTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/CallTarget.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -u -r1.27 -r1.28
  --- CallTarget.java	31 Jan 2003 06:49:44 -0000	1.27
  +++ CallTarget.java	31 Jan 2003 07:57:41 -0000	1.28
  @@ -188,13 +188,13 @@
       /**
        * Pass output sent to System.out to the new project.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleOutput(String line, boolean terminated) {
  +    public void handleFlush(String line) {
           if (callee != null) {
  -            callee.handleOutput(line, terminated);
  +            callee.handleFlush(line);
           } else {
  -            super.handleOutput(line, terminated);
  +            super.handleFlush(line);
           }
       }
       
  @@ -214,13 +214,13 @@
       /**
        * Pass output sent to System.err to the new project.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleErrorOutput(String line, boolean terminated) {
  +    public void handleErrorFlush(String line) {
           if (callee != null) {
  -            callee.handleErrorOutput(line, terminated);
  +            callee.handleErrorFlush(line);
           } else {
  -            super.handleErrorOutput(line, terminated);
  +            super.handleErrorFlush(line);
           }
       }
   }
  
  
  
  1.52      +8 -16     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
  
  Index: Java.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -w -u -r1.51 -r1.52
  --- Java.java	30 Jan 2003 15:12:52 -0000	1.51
  +++ Java.java	31 Jan 2003 07:57:41 -0000	1.52
  @@ -376,17 +376,13 @@
       /**
        * Pass output sent to System.out to specified output file.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleOutput(String line, boolean terminated) {
  +    protected void handleFlush(String line) {
           if (outStream != null) {
  -            if (terminated) {
  -                outStream.println(line);
  -            } else {
                   outStream.print(line);
  -            }
           } else {
  -            super.handleOutput(line, terminated);
  +            super.handleFlush(line);
           }
       }
       
  @@ -406,17 +402,13 @@
       /**
        * Pass output sent to System.err to specified output file.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleErrorOutput(String line, boolean terminated) {
  +    protected void handleErrorFlush(String line) {
           if (outStream != null) {
  -            if (terminated) {
                   outStream.println(line);
               } else {
  -                outStream.print(line);
  -            }
  -        } else {
  -            super.handleErrorOutput(line, terminated);
  +            super.handleErrorOutput(line);
           }
       }
       
  
  
  
  1.55      +12 -12    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -w -u -r1.54 -r1.55
  --- JUnitTask.java	30 Jan 2003 15:12:53 -0000	1.54
  +++ JUnitTask.java	31 Jan 2003 07:57:41 -0000	1.55
  @@ -717,16 +717,16 @@
        * Pass output sent to System.out to the TestRunner so it can
        * collect ot for the formatters.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleOutput(String line, boolean terminated) {
  +    protected void handleFlush(String line) {
           if (runner != null) {
  -            runner.handleOutput(line, terminated);
  +            runner.handleFlush(line);
               if (showOutput) {
  -                super.handleOutput(line, terminated);
  +                super.handleFlush(line);
               }
           } else {
  -            super.handleOutput(line, terminated);
  +            super.handleFlush(line);
           }
       }
   
  @@ -736,7 +736,7 @@
        *
        * @since Ant 1.5
        */
  -    protected void handleErrorOutput(String line) {
  +    public void handleErrorOutput(String line) {
           if (runner != null) {
               runner.handleErrorOutput(line);
               if (showOutput) {
  @@ -752,16 +752,16 @@
        * Pass output sent to System.err to the TestRunner so it can
        * collect ot for the formatters.
        *
  -     * @since Ant 1.6
  +     * @since Ant 1.5.2
        */
  -    protected void handleErrorOutput(String line, boolean terminated) {
  +    public void handleErrorFlush(String line) {
           if (runner != null) {
  -            runner.handleErrorOutput(line, terminated);
  +            runner.handleErrorFlush(line);
               if (showOutput) {
  -                super.handleErrorOutput(line, terminated);
  +                super.handleErrorFlush(line);
               }
           } else {
  -            super.handleErrorOutput(line, terminated);
  +            super.handleErrorFlush(line);
           }
       }
   
  
  
  
  1.29      +4 -12     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  
  Index: JUnitTestRunner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -w -u -r1.28 -r1.29
  --- JUnitTestRunner.java	30 Jan 2003 15:12:53 -0000	1.28
  +++ JUnitTestRunner.java	31 Jan 2003 07:57:42 -0000	1.29
  @@ -416,23 +416,15 @@
           }
       }
       
  -    protected void handleOutput(String line, boolean terminated) {
  +    protected void handleFlush(String line) {
           if (systemOut != null) {
  -            if (terminated) {
  -                systemOut.println(line);
  -            } else {
                   systemOut.print(line);
               }
           }
  -    }
       
  -    protected void handleErrorOutput(String line, boolean terminated) {
  +    protected void handleErrorFlush(String line) {
           if (systemError != null) {
  -            if (terminated) {
  -                systemError.println(line);
  -            } else {
                   systemError.print(line);
  -            }
           }
       }
       
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ant-dev-help@jakarta.apache.org


Mime
View raw message