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 Thu, 30 Jan 2003 15:12:56 GMT
conor       2003/01/30 07:12:55

  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:
  Flush output of Java task when finished.
  Propagate indication of whether line is terminated or not
  through to project and tasks
  PR: 16555
  
  Revision  Changes    Path
  1.11      +16 -3     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.10
  retrieving revision 1.11
  diff -u -w -u -r1.10 -r1.11
  --- DemuxOutputStream.java	25 Jul 2002 15:21:01 -0000	1.10
  +++ DemuxOutputStream.java	30 Jan 2003 15:12:52 -0000	1.11
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -191,8 +191,21 @@
        * @see Project#demuxOutput(String,boolean)
        */
       protected void processBuffer(ByteArrayOutputStream buffer) {
  +        processBuffer(buffer, true);
  +    }
  +
  +    /**
  +     * Converts the buffer to a string and sends it to the project.
  +     *
  +     * @param buffer the ByteArrayOutputStream used to collect the output
  +     * until a line separator is seen.
  +     * 
  +     * @see Project#demuxOutput(String,boolean)
  +     */
  +    protected void processBuffer(ByteArrayOutputStream buffer, 
  +                                 boolean terminated) {
           String output = buffer.toString();
  -        project.demuxOutput(output, isErrorStream);
  +        project.demuxOutput(output, isErrorStream, terminated);
           resetBufferInfo();
       }
   
  @@ -217,7 +230,7 @@
       public void flush() throws IOException {
           BufferInfo bufferInfo = getBufferInfo();
           if (bufferInfo.buffer.size() > 0) {
  -            processBuffer(bufferInfo.buffer);
  +            processBuffer(bufferInfo.buffer, false);
           }
       }
   }
  
  
  
  1.126     +20 -3     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.125
  retrieving revision 1.126
  diff -u -w -u -r1.125 -r1.126
  --- Project.java	24 Jan 2003 14:18:20 -0000	1.125
  +++ Project.java	30 Jan 2003 15:12:52 -0000	1.126
  @@ -1228,18 +1228,35 @@
        *        or information (<code>false</code>).
        */
       public void demuxOutput(String line, boolean isError) {
  +        demuxOutput(line, isError, true);
  +    }
  +
  +    /**
  +     * Demultiplexes output so that each task receives the appropriate
  +     * messages. If the current thread is not currently executing a task,
  +     * the message is logged directly.
  +     *
  +     * @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) {
           Task task = (Task) threadTasks.get(Thread.currentThread());
           if (task == null) {
               fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO);
           } else {
               if (isError) {
  -                task.handleErrorOutput(line);
  +                task.handleErrorOutput(line, terminated);
               } else {
  -                task.handleOutput(line);
  +                task.handleOutput(line, terminated);
               }
           }
       }
   
  +    
  +    
       /**
        * Executes the specified target and any targets it depends on.
        *
  
  
  
  1.37      +23 -1     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.36
  retrieving revision 1.37
  diff -u -w -u -r1.36 -r1.37
  --- Task.java	22 Aug 2002 17:32:21 -0000	1.36
  +++ Task.java	30 Jan 2003 15:12:52 -0000	1.37
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -298,6 +298,17 @@
        * @param line The line of output to log. Should not be <code>null</code>.
        */
       protected void handleOutput(String line) {
  +        handleOutput(line + "X7", true);
  +    }
  +
  +    /**
  +     * 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
  +     */
  +    protected void handleOutput(String line, boolean terminated) {
           log(line, Project.MSG_INFO);
       }
   
  @@ -307,6 +318,17 @@
        * @param line The error line to log. Should not be <code>null</code>.
        */
       protected void handleErrorOutput(String line) {
  +        handleErrorOutput(line, true);
  +    }
  +
  +    /**
  +     * 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
  +     */
  +    protected void handleErrorOutput(String line, boolean terminated) {
           log(line, Project.MSG_ERR);
       }
   
  
  
  
  1.35      +27 -0     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.34
  retrieving revision 1.35
  diff -u -w -u -r1.34 -r1.35
  --- UnknownElement.java	6 Jan 2003 07:30:34 -0000	1.34
  +++ UnknownElement.java	30 Jan 2003 15:12:52 -0000	1.35
  @@ -157,6 +157,19 @@
       }
   
       /**
  +     * Handles output sent to System.out by this task or its real task.
  +     *
  +     * @param line The line of output to log. Should not be <code>null</code>.
  +     */
  +    protected void handleOutput(String line, boolean terminated) {
  +        if (realThing instanceof Task) {
  +            ((Task) realThing).handleOutput(line, terminated);
  +        } else {
  +            super.handleOutput(line, terminated);
  +        }
  +    }
  +
  +    /**
        * Handles error output sent to System.err by this task or its real task.
        *
        * @param line The error line to log. Should not be <code>null</code>.
  @@ -169,6 +182,20 @@
           }
       }
   
  +
  +    /**
  +     * Handles error output sent to System.err by this task or its real task.
  +     *
  +     * @param line The error line to log. Should not be <code>null</code>.
  +     */
  +    protected void handleErrorOutput(String line, boolean terminated) {
  +        if (realThing instanceof Task) {
  +            ((Task) realThing).handleErrorOutput(line, terminated);
  +        } else {
  +            super.handleErrorOutput(line, terminated);
  +        }
  +    }
  +    
       /**
        * Executes the real object if it's a task. If it's not a task
        * (e.g. a data type) then this method does nothing.
  
  
  
  1.71      +26 -0     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.70
  retrieving revision 1.71
  diff -u -w -u -r1.70 -r1.71
  --- Ant.java	6 Jan 2003 14:12:36 -0000	1.70
  +++ Ant.java	30 Jan 2003 15:12:52 -0000	1.71
  @@ -297,6 +297,19 @@
       }
   
       /**
  +     * Pass output sent to System.out to the new project.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleOutput(String line, boolean terminated) {
  +        if (newProject != null) {
  +            newProject.demuxOutput(line, false, terminated);
  +        } else {
  +            super.handleOutput(line, terminated);
  +        }
  +    }
  +
  +    /**
        * Pass output sent to System.err to the new project.
        *
        * @since Ant 1.5
  @@ -306,6 +319,19 @@
               newProject.demuxOutput(line, true);
           } else {
               super.handleErrorOutput(line);
  +        }
  +    }
  +
  +    /**
  +     * Pass output sent to System.err to the new project.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleErrorOutput(String line, boolean terminated) {
  +        if (newProject != null) {
  +            newProject.demuxOutput(line, true, terminated);
  +        } else {
  +            super.handleErrorOutput(line, terminated);
           }
       }
   
  
  
  
  1.26      +26 -1     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.25
  retrieving revision 1.26
  diff -u -w -u -r1.25 -r1.26
  --- CallTarget.java	25 Jul 2002 15:21:04 -0000	1.25
  +++ CallTarget.java	30 Jan 2003 15:12:52 -0000	1.26
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -186,6 +186,19 @@
       }
       
       /**
  +     * Pass output sent to System.out to the new project.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleOutput(String line, boolean terminated) {
  +        if (callee != null) {
  +            callee.handleOutput(line, terminated);
  +        } else {
  +            super.handleOutput(line, terminated);
  +        }
  +    }
  +    
  +    /**
        * Pass output sent to System.err to the new project.
        *
        * @since Ant 1.5
  @@ -198,4 +211,16 @@
           }
       }
       
  +    /**
  +     * Pass output sent to System.err to the new project.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleErrorOutput(String line, boolean terminated) {
  +        if (callee != null) {
  +            callee.handleErrorOutput(line, terminated);
  +        } else {
  +            super.handleErrorOutput(line, terminated);
  +        }
  +    }
   }
  
  
  
  1.51      +37 -1     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.50
  retrieving revision 1.51
  diff -u -w -u -r1.50 -r1.51
  --- Java.java	25 Jul 2002 15:21:05 -0000	1.50
  +++ Java.java	30 Jan 2003 15:12:52 -0000	1.51
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -374,6 +374,23 @@
       }
       
       /**
  +     * Pass output sent to System.out to specified output file.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleOutput(String line, boolean terminated) {
  +        if (outStream != null) {
  +            if (terminated) {
  +                outStream.println(line);
  +            } else {
  +                outStream.print(line);
  +            }
  +        } else {
  +            super.handleOutput(line, terminated);
  +        }
  +    }
  +    
  +    /**
        * Pass output sent to System.err to specified output file.
        *
        * @since Ant 1.5
  @@ -387,6 +404,23 @@
       }
       
       /**
  +     * Pass output sent to System.err to specified output file.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleErrorOutput(String line, boolean terminated) {
  +        if (outStream != null) {
  +            if (terminated) {
  +                outStream.println(line);
  +            } else {
  +                outStream.print(line);
  +            }
  +        } else {
  +            super.handleErrorOutput(line, terminated);
  +        }
  +    }
  +    
  +    /**
        * Executes the given classname with the given arguments as it
        * was a command line application.
        */
  @@ -402,6 +436,8 @@
                       new PrintStream(new FileOutputStream(out.getAbsolutePath(),
                                                            append));
                   exe.execute(getProject());
  +                System.out.flush();
  +                System.err.flush();
               } catch (IOException io) {
                   throw new BuildException(io, getLocation());
               } finally {
  
  
  
  1.54      +36 -1     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.53
  retrieving revision 1.54
  diff -u -w -u -r1.53 -r1.54
  --- JUnitTask.java	24 Jan 2003 14:34:49 -0000	1.53
  +++ JUnitTask.java	30 Jan 2003 15:12:53 -0000	1.54
  @@ -714,6 +714,23 @@
       }
   
       /**
  +     * Pass output sent to System.out to the TestRunner so it can
  +     * collect ot for the formatters.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleOutput(String line, boolean terminated) {
  +        if (runner != null) {
  +            runner.handleOutput(line, terminated);
  +            if (showOutput) {
  +                super.handleOutput(line, terminated);
  +            }
  +        } else {
  +            super.handleOutput(line, terminated);
  +        }
  +    }
  +
  +    /**
        * Pass output sent to System.err to the TestRunner so it can
        * collect ot for the formatters.
        *
  @@ -727,6 +744,24 @@
               }
           } else {
               super.handleErrorOutput(line);
  +        }
  +    }
  +
  +
  +    /**
  +     * Pass output sent to System.err to the TestRunner so it can
  +     * collect ot for the formatters.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected void handleErrorOutput(String line, boolean terminated) {
  +        if (runner != null) {
  +            runner.handleErrorOutput(line, terminated);
  +            if (showOutput) {
  +                super.handleErrorOutput(line, terminated);
  +            }
  +        } else {
  +            super.handleErrorOutput(line, terminated);
           }
       }
   
  
  
  
  1.28      +21 -1     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.27
  retrieving revision 1.28
  diff -u -w -u -r1.27 -r1.28
  --- JUnitTestRunner.java	6 Nov 2002 11:18:55 -0000	1.27
  +++ JUnitTestRunner.java	30 Jan 2003 15:12:53 -0000	1.28
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -413,6 +413,26 @@
       protected void handleErrorOutput(String line) {
           if (systemError != null) {
               systemError.println(line);
  +        }
  +    }
  +    
  +    protected void handleOutput(String line, boolean terminated) {
  +        if (systemOut != null) {
  +            if (terminated) {
  +                systemOut.println(line);
  +            } else {
  +                systemOut.print(line);
  +            }
  +        }
  +    }
  +    
  +    protected void handleErrorOutput(String line, boolean terminated) {
  +        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