Chris Lambrou <[EMAIL PROTECTED]> wrote:

> Craig,
>
> We use a slightly modified version of NUnit, and often we wrap it in
> NCover.Console.exe, so we run it using an <exec/> task, rather than
> using NAnt's <nunit/> task. However, even if NUnit returns with a
> non-zero error code, we don't allow this to immediately fail the
> build (the <exec/> task for NUnit has failonerror="false"), as we
> usually want to continue the build process in order perform
> subsequent analysis.

We had this problem when we started using both NUnit (actually NCover 
*calling* NUnit) and FxCop in our builds.  We solved it by deciding that 
testing was more important, so we put that one first, and it fails the 
build if testing fails.  If FxCop gets to run, it then gets its chance 
to fail. :)

> For example, we run a tool that converts the
> NCover analysis files into a pretty set of HTML files, and we
> subsequently run FxCop, too.

This can be resolved by judicious use of CC.NET's capabilities.  We use 
the merge task in the publishers section to make sure that all the logs 
created by the various tools are merged into CC.NET's log for the 
application, then tell CC.NET which XSL to use to render the contents 
into pretty pictures.

The  merge strategy works because CC.NET will always execute the tasks 
in the publishers section, even if something in the tasks section fails.

> this check in a target defined by nant.onsuccess is the ideal place
> to do this check, except that calling <fail/> in this target doesn't
> cause NAnt to terminate with a non-zero exit code, as would be the
> case if <fail/> was called in any other target.

When we did this (we don't anymore, prefering the simplicity of failing 
as soon as we get a test error), we created a target that called all the 
targets we wanted to run.  Each of those targets reported the result to 
a property.  Then the main target decided whether or not an error 
happened and failed, after executing all the targets.  Something along 
these lines:

<project name="Testing" default="run">

    <property name="target1Result" value="fail" />
    <property name="target2Result" value="fail" />

    <target name="target1" failonerror="true">
        <echo message="Show ${undefinedProperty}" />
        <property name="target1Result" value="success" />
    </target>

    <target name="target2" failonerror="true">
        <echo message="target2 execution" />
        <property name="target2Result" value="success" />
    </target>

    <target name="run">
        <echo message="main target" />

        <call target="target1"  failonerror="false"/>
        <call target="target2"  failonerror="false"/>

        <fail message="target1 failed" 
if="${property::get-value('target1Result')=='fail'}" />
        <fail message="target2 failed" 
if="${property::get-value('target2Result')=='fail'}" />

    </target>

</project>

Brad 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to