ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ondrej Svetlik <ond...@svetlik.info>
Subject Re: Testing multiple values?
Date Tue, 20 Dec 2005 21:52:16 GMT
Well, how about

<exec />
<fail message="Script1 failed. See Script1.out.">
	<condition>
		<equals arg1="${script1.result}" arg2="1" />
	</condition>
</fail>

<fail message="WinSCP3 environment not initialized. Please click on the 
keyfile and supply the passphrase.">
	<condition>
		<equals arg1="${script1.result}" arg2="-1073741819" />
	</condition>
</fail>

Best regards,

Ondrej Svetlik

Rhino wrote:
> How do I handle three different possible values from an 'exec' task when 
> I want one value to be ignored and each of the other two values to 
> invoke different targets?
> 
> I have an exec task that has the parameter 
> resultproperty="script1.result". The value of script1.result can be: 0 
> (indicates that the script worked fine without errors); 1 (indicates 
> that the script ran but had errors); or -1073741819 (indicates that the 
> WinSCP3 environment was not initialized properly; basically, the 
> passphrase hadn't yet been entered so that WinSCP3 could verify the login).
> 
> When script.result is 0, I want to move on to the next target within my 
> build. When script.result is 1, I want to fail with the error message 
> ("Script1 failed. See Script1.out."). When script1.result is
> -1073741819, I want to fail with the error message ("WinSCP3 environment 
> not initialized. Please click on the keyfile and supply the passphrase.")
> 
> My script currently handles the 0 and 1 conditions just fine but I don't 
> know how to change my code to handle the third value for script1.result. 
> Here is what I have so far:
> 
> <target name="upload-Tonge" description="Upload to the Tonge server.">
> 
> <echo message="Uploading to Tonge...."/>
> 
> <!--echoproperties prefix="server"/-->
> 
> <exec executable="${WinSCP3.com}" os="Windows XP" 
> output="${script1.out}" error="${script1.err}"
> 
> resultproperty="script1.result"
> 
> description="Run a trivial script that doesn't change anything, just to 
> show that everything works.">
> 
> <arg line="/console /script=${script1.in}"/>
> 
> </exec>
> 
> 
> 
> </target>
> 
> <target name="check-Script1" depends="upload-Tonge" description="See if 
> Script1 worked.">
> 
> <echo message="Check script1 result"/>
> 
> <condition property="script1.failed">
> 
> <equals arg1="${script1.result}" arg2="1"/>
> 
> </condition>
> 
> <echo message="script1.result=${script1.result}"/>
> 
> <antcall target="upload-Tonge-Script1-errors"/>
> 
> </target>
> 
> <target name="upload-Tonge-Script1-errors" if="script1.failed">
> 
> <fail message="Oops, script ${script1.name} failed on Tonge server. See 
> ${script1.out} and ${script1.err}."/>
> 
> </target>
> 
> 
> 
> <target name="upload-Tonge-Script2-errors" if="script2.failed">
> 
> <fail message="Oops, script ${script2.name} failed on Tonge server. See 
> ${script2.out} and/or ${script2.err}."/>
> 
> </target>
> 
> 
> Do I need a different condition task to handle the -1073741819 value for 
> script1.result? If yes, don't I have to worry about the 'upload-Bongo' 
> task executing twice? Or can I modify the existing condition task to 
> invoke two different targets based on the non-zero value of 
> script.result, one target for script1.result = 1 and a different target 
> for script1.result = -1073741819?
> 
> Or do I need to change the script more radically and do things a whole 
> different way?
> 
> I'd prefer to stay with core tasks if at all possible.
> 
> Rhino
> 
> 
> 

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


Mime
View raw message