You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2001/07/21 15:06:28 UTC

[Bug 314] - Return value in bin/runant.pl script BugRat Report#572

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=314

*** shadow/314	Sun May 20 17:19:42 2001
--- shadow/314.tmp.13003	Sat Jul 21 06:06:28 2001
***************
*** 1,19 ****
! Bug#: 314
! Product: Ant
! Version: 1.2
! Platform: All
! OS/Version: All
! Status: UNCONFIRMED   
! Resolution: 
! Severity: Normal
! Priority: High
! Component: Wrapper scripts
! AssignedTo: ant-dev@jakarta.apache.org                            
! ReportedBy: sknippenberg@unwiredexpress.com               
! URL: 
! Cc: 
! Summary: Return value in bin/runant.pl script BugRat Report#572
! 
  On Windows 2000, both the perl script and the batch file do not return the return value that was returned by the Java ant code. This makes it difficult to use in automated scripts that run at night that need to evaluate whether to continue, or to stop and report failure. 
  
  I would like to request a change to the perl script (I'm not sure if it's possible to evaluate and return values in a windows script). I attached some code in the work around section that will do this.
--- 1,19 ----
! +============================================================================+
! | Return value in bin/runant.pl script BugRat Report#572                     |
! +----------------------------------------------------------------------------+
! |        Bug #: 314                         Product: Ant                     |
! |       Status: RESOLVED                    Version: 1.2                     |
! |   Resolution: FIXED                      Platform: All                     |
! |     Severity: Normal                   OS/Version: All                     |
! |     Priority: High                      Component: Wrapper scripts         |
! +----------------------------------------------------------------------------+
! |  Assigned To: ant-dev@jakarta.apache.org                                   |
! |  Reported By: sknippenberg@unwiredexpress.com                              |
! |      CC list: Cc:                                                          |
! +----------------------------------------------------------------------------+
! |          URL:                                                              |
! +============================================================================+
! |                              DESCRIPTION                                   |
  On Windows 2000, both the perl script and the batch file do not return the return value that was returned by the Java ant code. This makes it difficult to use in automated scripts that run at night that need to evaluate whether to continue, or to stop and report failure. 
  
  I would like to request a change to the perl script (I'm not sure if it's possible to evaluate and return values in a windows script). I attached some code in the work around section that will do this.
***************
*** 44,46 ****
--- 44,49 ----
  Applied the patch to the Perl script. Should appear in nightly build 2000-03-17.
  
  Any takers for the Windows batch files?
+ 
+ ------- Additional Comments From conor@cortexebusiness.com.au  2001-07-21 06:06 -------
+ Added return codes to the windows batch file

Re: [Bug 314] - Return value in bin/runant.pl script BugRat Report#572

Posted by Peter Donald <do...@apache.org>.
On Sun, 22 Jul 2001 20:11, Conor MacNeill wrote:
> The only issue will be if someone executes a command in antrc_post which
> will reset the errorlevel. I did play around with the choice command but it
> is an ugly hack :-(. Batch file error management is really a shocker.

Shouldn't that be "Batch file management is really a shocker."? Though I 
would probably use the word horror rather than shocker ;)

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

Re: [Bug 314] - Return value in bin/runant.pl script BugRat Report#572

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
From: "Nico Seessle" <ni...@apache.org>
To: <an...@jakarta.apache.org>
Sent: Sunday, July 22, 2001 5:01 AM
Subject: Re: [Bug 314] - Return value in bin/runant.pl script BugRat
Report#572
>
> So it does not work.

:-) You are right. Interestingly my testing worked, so I now realize that
under NT, at least, this has always
worked. The errorlevel is as set by the previous command which was the java
command that ran ant.

And the exit did indeed close my window which is not cool :-)

So, I have backed out the change and I believe it should work anyway. Can
you please test in Win9X. BTW, here is the test batch file I am using

-----------------------------
@echo off
call ant %*
if errorlevel 1 goto failed

echo ok
goto end

:failed
echo failed

:end
-----------------------------

The only issue will be if someone executes a command in antrc_post which
will reset the errorlevel. I did play around with the choice command but it
is an ugly hack :-(. Batch file error management is really a shocker.

Thanks
Conor




Re: [Bug 314] - Return value in bin/runant.pl script BugRat Report#572

Posted by Nico Seessle <ni...@apache.org>.
----- Original Message -----
From: <bu...@apache.org>
To: <an...@jakarta.apache.org>; <sk...@unwiredexpress.com>
Sent: Saturday, July 21, 2001 3:06 PM
Subject: [Bug 314] - Return value in bin/runant.pl script BugRat Report#572


 > + ------- Additional Comments From conor@cortexebusiness.com.au
2001-07-21 06:06 -------
> + Added return codes to the windows batch file

OK, the last line does now read "if %ANT_ERROR%=="yes" exit 1".

I have run the following build.xml

<?xml version="1.0"?>
<project default="main">
  <target name="main">
    <echo amessage="${java.home}"/>
  </target>
</project>

and I really expect it to fail. I removed "@echo off" from the first line of
ant.bat and get

main:

BUILD FAILED

C:\temp\build.xml:4: The <echo> task doesn't support the "amessage"
attribute.

Total time: 1 second

C:\temp>goto end
C:\temp>if errorlevel 1 set ANT_ERROR=yes
C:\temp>set LOCALCLASSPATH=
C:\temp>set _JAVACMD=
C:\temp>set ANT_CMD_LINE_ARGS=
C:\temp>if not "Windows_NT" == "Windows_NT" goto mainEnd
C:\temp>if yes == yes goto winNTError
C:\temp>set ANT_ERROR=yes
C:\temp>goto :mainEnd
C:\temp>if exist "\antrc_post.bat" call "\antrc_post.bat"
C:\temp>if yes == "yes" exit 1

So it does not work.

If I "repair" it by changing the last line to read "if "%ANT_ERROR%"=="yes"
exit 1" (setting the variable in quotes) you may call it "working" - I think
it will return 1, but it closes my cmd.exe (caused by the exit) so I will
never know (And I will not use it as is).

On which OS are you running Ant?

Nico