haw*_*eye 5 haskell haskell-stack
我正在克隆以下存储库并stack.yaml通过在末尾添加对进行一项更改:
docker:
enable: true
Run Code Online (Sandbox Code Playgroud)
运行haskoin-core我正在使用的所有测试
stack test haskoin-core:test-haskoin-core
Run Code Online (Sandbox Code Playgroud)
我想做的只是运行一个测试。如果是这样的HSpec(这是不是)我会运行类似:
stack test --test-arguments -m "Network.Haskoin.Network.Units"
Run Code Online (Sandbox Code Playgroud)
现在我可以做的是修改文件haskcoin-core/test/Main.hs并注释掉所有我不想运行的测试。但是你知道 - 应该有一种更简单的方法来运行它,只使用命令行参数。(改变文件系统会影响 Haskell 的整个功能)。
我也愿意以stack ghci某种方式运行它。
我的问题是:如何使用 Stack 和 Haskell Test.Framework 运行单个测试?
截至2019年中期,我认为stack已经发生了变化。
请参阅--help选项:
stack test --test-arguments "--help"
执行 a--dry-run查看将运行哪些测试:
stack test --test-arguments "--dry-run"
选择带有 的测试--match。请注意,这声称全局模式可以工作,但它们似乎不适合我:
stack test --test-arguments "--match=foobar"
AFAICT,"foobar"被解释为一团*foobar*,但我不能明确说明它。
感谢@sjakobi 的回答。
该过程是 - 列出可用的测试命令:
stack test --test-arguments "--help" haskoin-core:test-haskoin-core
Run Code Online (Sandbox Code Playgroud)
这给出了以下结果:
haskoin-core-0.4.2: test (suite: test-haskoin-core, args: --help)
Usage: test-haskoin-core [OPTIONS]
--help show this help message
-j NUMBER --threads=NUMBER number of threads to use to run tests
--test-seed=NUMBER|random default seed for test random number generator
-a NUMBER --maximum-generated-tests=NUMBER how many automated tests something like QuickCheck should try, by default
--maximum-unsuitable-generated-tests=NUMBER how many unsuitable candidate tests something like QuickCheck should endure before giving up, by default
-s NUMBER --maximum-test-size=NUMBER to what size something like QuickCheck should test the properties, by default
-d NUMBER --maximum-test-depth=NUMBER to what depth something like SmallCheck should test the properties, by default
-o NUMBER --timeout=NUMBER how many seconds a test should be run for before giving up, by default
--no-timeout specifies that tests should be run without a timeout, by default
-l --list-tests list available tests but don't run any; useful to guide subsequent --select-tests
-t TEST-PATTERN --select-tests=TEST-PATTERN only tests that match at least one glob pattern given by an instance of this argument will be run
--jxml=FILE write a JUnit XML summary of the output to FILE
--jxml-nested use nested testsuites to represent groups in JUnit XML (not standards compliant)
--plain do not use any ANSI terminal features to display the test run
--color use ANSI terminal features to display the test run
--hide-successes hide sucessful tests, and only show failures
Test suite failure for package haskoin-core-0.4.2
test-haskoin-core: exited with: ExitFailure 1
Logs printed to console
Run Code Online (Sandbox Code Playgroud)
由此我们可以构建一个命令来列出测试:
stack test --test-arguments "--list-tests" haskoin-core:test-haskoin-core
Run Code Online (Sandbox Code Playgroud)
从那里我们可以使用此命令来进行特定测试
stack test --test-arguments=--select-tests=Bloom*Filter haskoin-core:test-haskoin-core
Run Code Online (Sandbox Code Playgroud)
请注意*空格的位置,似乎有一些 关于如何在这种情况下处理空格的讨论。
现在选择我们想要运行的测试:
haskoin-core-0.4.2: test (suite: test-haskoin-core, args: --select-tests=Bloom*Filter)
Binary encoding and decoding of bloom types:
BloomFilter: [OK, passed 100 tests]
Bloom Filters:
Bloom Filter Vector 1: [OK]
Bloom Filter Vector 2: [OK]
Bloom Filter Vector 3: [OK]
Properties Test Cases Total
Passed 1 3 4
Failed 0 0 0
Total 1 3 4
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1268 次 |
| 最近记录: |