获取堆栈以通过测试套件名称作为--test-arguments的一部分 [英] Get Stack to pass test suite name as part of --test-arguments
问题描述
使用cabal,可以建立连续的构建,以许多CI系统会接受的格式记录测试成功/失败的命令,例如:
It's possible, with cabal, to set up a continuous build that records test successes/failures in a format many CI systems will accept with a command like:
cabal test '--test-option=--jxml=test-results/$test-suite.xml'
这里的重要部分是将$test-suite
替换为测试名称,以便不同的测试将其结果放入不同的文件中.
The important part here is that $test-suite
is replaced with the name of the test, so that different tests put their results into different files.
当我使用堆栈时,所有测试实际上都会获得选项--jxml=test-results/$test-suite.xml
传递给它们,因此最终结果是测试覆盖了彼此的结果.
When I use stack, all tests get literally the option --jxml=test-results/$test-suite.xml
passed to them, so the end result is that the tests overwrite each others' results.
是否可以使用stack
运行我的所有测试,以便告诉每个测试套件一个不同的位置来编写其结果?
Is there any way to run all my tests with stack
so that I can tell each test suite a different place to write their results?
我什至会接受一些堆栈命令来为我解析cabal文件并告诉我其中有什么测试套件,因为这样我就可以在bash中编写一个脚本循环,一次调用每个测试套件.
I'd even accept some stack command that parsed the cabal file for me and told me what test suites there are, because then I could script a loop in bash calling each test one at a time.
推荐答案
我什至会接受一些堆栈命令来为我解析cabal文件并告诉我其中有什么测试套件,因为这样我就可以在bash中编写一个脚本循环,一次调用每个测试套件.
I'd even accept some stack command that parsed the cabal file for me and told me what test suites there are, because then I could script a loop in bash calling each test one at a time.
如果您愿意屈服于此,stack ide targets
将返回目标列表,您可以从中进行一些猛击以获得测试套件列表.像这样:
If you're willing to stoop to that, stack ide targets
will return a list of targets, from which you can do some bashing to get the list of test suites. Something like this:
stack ide targets 2>&1 |
while IFS=: read pkg type suite; do
[[ $type = test ]] && stack test ":$suite" --test-arguments="--jxml=test-results/$suite.xml"
done
这篇关于获取堆栈以通过测试套件名称作为--test-arguments的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!