【问题标题】:Can Ant load a URL?Ant 可以加载 URL 吗?
【发布时间】:2016-06-21 20:55:08
【问题描述】:

我有一个 Ant 构建脚本,它当前启动一个服务器,然后等待一个 URL 可以被解析,然后再为我执行一些 Selenium 测试。该任务如下所示;

<target name="test.selenium" depends="compile.constants, launch.server" description="Run the Selenium tests">
    <echodesc/>
    <waitfor maxwait="1" maxwaitunit="minute" checkevery="2" checkeveryunit="second">
        <http url="http://127.0.0.1:${product.listenport}/"/>
    </waitfor>
    <exec executable="${deps.python}" spawn="false" failonerror="true" dir="src">
        <arg line="manage.py test --selenium-only" />
    </exec>
</target>

成功之后,我想调用一个 URL 来关闭服务器,但我不确定如何使用 Ant 执行此操作。是否可以让 Ant 调用127.0.0.1:${product.listenport}/QUIT

我之前是通过对正在运行的进程使用taskkill 命令来实现这一点的,但这已经开始导致 Windows 错误,并且该 URL 干净地关闭了服务器。

我能找到的最佳解决方案是在浏览器中打开 URL 的宏,但这仍然会给我带来问题,因为我在测试结束时打开了浏览器; http://chris.m0nk3y.net/blog/post/opening-a-url-in-the-default-browser-with-ant

我的解决方案

最终我使用了以下蚂蚁目标;

<target name="shutdown.server" depends="init.properties" description="Shutdown the server">
    <get src="http://127.0.0.1:${product.listenport}/QUIT" dest="NUL"/>
</target>

'NUL' 使我能够使用 get 而无需处理正在创建的新文件,因此这非常适合这项工作 \o/

【问题讨论】:

  • 就是这样! dest="NUL" 是我正在寻找的提示!

标签: ant


【解决方案1】:

您可以使用get 任务调用http url。这里有更多信息https://ant.apache.org/manual/Tasks/get.html

例如&lt;get src="http://127.0.0.1:${product.listenport}/QUIT" dest="${temp.dir}/quit.res"/&gt;

【讨论】:

    猜你喜欢
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多