I've found some issues in handling forced failures in NAnt v0.8.4.31128. What happens is that I have a nant.onfailure task set. Somewhere in the build script, I'm failing the build with <fail message="Failure reason" /> task. The onfailure handler calls a cleanup target that happens to have an error.
If the call to the cleanup task does not have failonerror="false" set, then the original fail message is never written out. (Scenario 1, failing-task.build). Not even the message BUILD FAILED is written at the end. On the other hand, if I set failonerror="false" when calling tasks from the onfailure handler, I get the message from my <fail> task (line 20 in scenario 2), which is expected behavior, although it would be much more useful if the same message would also appear on the line 5 in scenario 2, not just at the end with a file line number (line 19). The worst problem is if the task fails in the onfailure handler itself (scenario 3, failing-task2.build file). The original failure message is never printed out, no matter how failonerror is set on the failing task. One would expect that the original <fail> message always appear, regardless whether further errors are reported after <fail> task triggered the failure. In addition, in all three scenarios any <echo> message after the <fail> task is never printed out; only [echo] appears in the output. (Scenario 1, line 12; Scenario 2 lines 12 and 15; Scenario 3 lines 9 and 10). I suppose this is a bug. Damir Scenario 1: onfailure handler calling failing 'cleanup' target with failonerror="true": =========================================================================== 1: Buildfile: file:///C:/failing-task.build 2: Target(s) specified: fail 3: 4: fail: 5: 6: 7: handle-failure: 8: 9: 10: cleanup: 11: 12: [echo] 13: C:\failing-task.build(21,4): 14: Property 'build.dir' has not been set. 15: 16: For more information regarding the cause of the build failure, enable log4net using the instructions in NAnt.exe.config and run the build again. 17: Try 'nant -help' for more information Scenario 2: onfailure handler calling failing 'cleanup' target with failonerror="false": ============================================================================ 1: Buildfile: file:///C:/failing-task.build <file:///C:/failing-task.build> 2: Target(s) specified: fail 3: 4: fail: 5: 6: 7: handle-failure: 8: 9: 10: cleanup: 11: 12: [echo] 13: C:\failing-task.build(21,4): 14: Property 'build.dir' has not been set. 15: [echo] 16: 17: BUILD FAILED 18: 19: C:\failing-task.build(10,5): 20: ===> This message should announce the forced failure. 21: 22: Total time: 0.1 seconds. Scenario 3: onfailure handler calling failing 'delete' task with failonerror="false": ========================================================================= 1: Buildfile: file:///failing-task2.build <file:///failing-task2.build> 2: Target(s) specified: fail 3: 4:fail: 5: 6: 7:handle-failure: 8: 9: [echo] 10: [echo] 11: C:\failing-task2.build(16,4): 12: Property 'build.dir' has not been set. 13: 14: For more information regarding the cause of the build failure, enable log4net using the instructions in NAnt.exe.config and run the build again. 15: 16: Try 'nant -help' for more information
failing-task.build
Description: Binary data
failing-task2.build
Description: Binary data
onfailure handler calling failing 'cleanup' target with failonerror="true": =========================================================================== 1: Buildfile: file:///C:/failing-task.build 2: Target(s) specified: fail 3: 4: fail: 5: 6: 7: handle-failure: 8: 9: 10: cleanup: 11: 12: [echo] 13: C:\failing-task.build(21,4): 14: Property 'build.dir' has not been set. 15: 16: For more information regarding the cause of the build failure, enable log4net using the instructions in NAnt.exe.config and run the build again. 17: Try 'nant -help' for more information onfailure handler calling failing 'cleanup' target with failonerror="false": ============================================================================ 1: Buildfile: file:///C:/failing-task.build 2: Target(s) specified: fail 3: 4: fail: 5: 6: 7: handle-failure: 8: 9: 10: cleanup: 11: 12: [echo] 13: C:\failing-task.build(21,4): 14: Property 'build.dir' has not been set. 15: [echo] 16: 17: BUILD FAILED 18: 19: C:\failing-task.build(10,5): 20: ===> This message should announce the forced failure. 21: 22: Total time: 0.1 seconds. onfailure handler calling failing 'delete' task with failonerror="false": ========================================================================= 1: Buildfile: file:///failing-task2.build 2: Target(s) specified: fail 3: 4:fail: 5: 6: 7:handle-failure: 8: 9: [echo] 10: [echo] 11: C:\failing-task2.build(16,4): 12: Property 'build.dir' has not been set. 13: 14: For more information regarding the cause of the build failure, enable log4net using the instructions in NAnt.exe.config and run the build again. 15: 16: Try 'nant -help' for more information
