【发布时间】:2014-07-23 12:52:33
【问题描述】:
我尝试运行这个 gradle 任务(通过 gradlew)
使用黄瓜jvm
task callCL (type: Exec) {
commandLine './build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.mayApp.testing.cucumber src/main/resources/features --tags ~@ignore -f rerun'
}
得到这个错误
:callCL FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':callCL'.
> A problem occurred starting process 'command './build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.myApp.testing.cucumber src/main/resources/features --tags ~@ignore -f rerun''
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.448 secs
error=2, No such file or directory
3:48:00 PM: External task execution finished 'callCL'.
当我在 cmd 中从同一路径运行同一行时:
/build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.myApp.testing.cucumber src/main/resources/features --tags ~@ignore -f rerun
Starting ChromeDriver (v2.9.248307) on port 12095
Starting ChromeDriver (v2.9.248307) on port 34150
Starting ChromeDriver (v2.9.248307) on port 29495
Starting ChromeDriver (v2.9.248307) on port 8792
Starting ChromeDriver (v2.9.248307) on port 23779
Starting ChromeDriver (v2.9.248307) on port 3553
更新1:
此 cmd 在 shell 控制台中工作:
./build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.waze.testing.cucumber src/main /resources/features --tags @only -f rerun
但不在 build.gradle 中
task callCL (type: Exec) {
commandLine 'bash', './build/distributions/WebLargeTests/bin/WebLargeTests', '-f',
'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue',
'com.waze.testing.cucumber', 'src/main/resources/features', '--tags', '@ignore', '-f', 'rerun'
//store the output instead of printing to the console:
standardOutput = new ByteArrayOutputStream()
//extension method stopTomcat.output() can be used to obtain the output:
ext.output = {
return standardOutput.toString()
}
}
顺便说一句
我希望 cmd 是:
./build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.waze.testing.cucumber src/main /resources/features --tags @only -f rerun --out rerun.txt
但不在 build.gradle 中
task callCL (type: Exec) {
commandLine 'bash', './build/distributions/WebLargeTests/bin/WebLargeTests', '-f',
'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue',
'com.waze.testing.cucumber', 'src/main/resources/features', '--tags', '@ignore', '-f', 'rerun', '--out', 'rerun.txt'
//store the output instead of printing to the console:
standardOutput = new ByteArrayOutputStream()
//extension method stopTomcat.output() can be used to obtain the output:
ext.output = {
return standardOutput.toString()
}
}
但这不起作用(shell concole nore build.gradle)
【问题讨论】:
-
你肯定定义错了
commandLine。应该是例如:commandLine 'bash','script.sh' -
添加了
commandLine 'bash','并得到:进程 'command 'bash'' 以非零退出值 127 结束 -
这不是命令开头
bash的问题,而是所有命令args都应该用'单独转义。 -
所以我跑了:` task callCL (type: Exec) { commandLine 'bash', './build/distributions/WebLargeTests/bin/WebLargeTests', '-f', 'html:build/报告/黄瓜/','-f','json:build/reports/cucumber/report.json','--glue','com.waze.testing.cucumber','src/main/resources/features' , '--tags', '@ignore', '--out', 'rerun.txt' }` 得到:`:callCL FAILED FAILURE: Build failed with an exception。 * 出了什么问题:任务 ':callCL' 执行失败。 > 进程 'command 'bash'' 以非零退出值 1 结束
标签: java shell gradle cucumber cucumber-jvm