Ant 构建关闭 - Ctrl C
我有一组 ant 任务,用于运行我的测试套件,偶尔其中一个测试会冻结,并且我的整个测试套件会挂起。我添加了一个关闭处理程序,因此当我点击 Ctrl+C 时,ant 会正常关闭并给我一份报告,其中最终测试标记为未运行。 (这很重要,因为这些是集成测试,可以运行几个小时)这非常有效,除了在 Windows 上,我的关闭钩子没有被调用。有没有办法让 ant 响应任何类型的输入并正常关闭?
I have a set of ant tasks that I use to run my test suite, occasionally one of those tests will freeze and my entire test suite will hang. I added a shutdown handler so when I hit Ctrl+C ant will shutdown gracefully and give me a report with the final test marked as not run. (This is important because these are integration tests and can run for hours) This works great except for on Windows where my shutdown hook is not being called. Is there a way I can get ant to respond to any kind of input and do a graceful shutdown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是一个长期运行的已知问题。
问题在于,正如您所观察到的,在 Windows 上,Ant Ctrl+C 不会传播到子虚拟机。您可能会考虑的事项:
超时
来终止任何挂起的内容。这将限制挂起的一个测试丢失的数据。这看起来很复杂,但可能值得一试。您需要将 Ant
parallel
和input
任务结合起来,在一个线程中运行测试,并在第二个线程中等待来自控制台的输入。当选择中止时,信号文件被写入,这在测试运行“监听器”中被检测到,导致它终止。任何其他输入都会导致运行干净终止。这样做的问题是,如果测试成功完成,Ant 就会等待用户输入,但您可以为此设置一个整体超时。 (我没有给出测试运行代码如何检测信号文件的示例。)Psuedo-Ant:
It seems this is a long-running known issue.
The problem is that on Windows the Ant Ctrl+C is, as you have observed, not propagated to the child VMs. Things you might consider:
timeout
to kill anything that hangs. This will limit the data lost to the one test that hangs.This appears complex, but might be worth a shot. You'd need to combine the Ant
parallel
andinput
tasks to run the tests in one thread, and wait for input from the console in a second thread. When abort is chosen, the signal file is written, this is detected in the test run 'listener', causing it to terminate. Any other input would lead to clean termination of the run. The problem with this is that, if the test completes successfully, you're left with Ant waiting for user input, but you could put an overall timeout in place for that. (I've not given an example of how the test run code might detect the signal file.)Psuedo-Ant: