Ant build shutdown - Ctrl C

I have a set of ant tasks that I use to run my test suite, occasionally one of these tests will freeze, and the entire test suite will freeze. I added a shutdown handler, so when I press Ctrl + C ant, you finish gracefully and give me a report with the final test, marked as not running. (This is important because it is integration tests and can work for several hours). This works fine except for Windows where my call is disconnected. Is there a way that I can get ant to respond to any input and make a graceful shutdown?

+4
source share
1 answer

This seems to be a long known issue .

The problem is that in Windows Ant, Ctrl + C , as you saw, does not apply to child virtual machines. What you might think:

  • Break the test into smaller parts and use timeout to kill everything that hangs. This will limit the data lost for one test that is hanging.
  • In the test run, add the listener thread, which waits for the shutdown signal (possibly the flag file) and organizes the configuration of this signal using Ant upon command from the console if a freeze is detected.

It seems complicated, but it may be worth it. You will need to combine Ant parallel and input tasks to run the tests in one thread and wait for input from the console in the second thread. When an interrupt is selected, a signal file is written, this is detected in the listener test run, as a result of which it ends. Any other input will result in a clean shutdown. The problem is that if the test is successful, you are left with Ant waiting for user input, but you can set a common timeout for this. (I did not give an example of how test run code can detect a signal file.)

Psuedo- Ant:

 <property name="signal.abort" value="stop.txt" /> <target name="runner"> <delete file="${signal.abort}" /> <parallel timeout="86400000"> <sequential> <!-- run tests here --> </sequential> <sequential> <input validargs="y,n" message="Abort the test (y/n)?" addproperty="abort.test" /> <condition property="do.abort"> <equals arg1="y" arg2="${abort.test}"/> </condition> <ant target="terminator" /> </sequential> </parallel> </target> <target name="terminator" if="do.abort"> <echo message="abort" file="${signal.abort}" /> </target> 
+2
source

All Articles