Haskell Stack Ghci测试套件 [英] Haskell Stack Ghci test-suite
问题描述
我试图用堆栈来加载ghci中的测试套件,并加载QuickCheck和hspec依赖项。
我该如何做? / p>
我使用的是franklinchen模板。
https://github.com/commercialhaskell/stack-templates/ blob / master / franklinchen.hsfiles
我试过了
堆栈ghci spec
stack ghci test-suite
stack ghci --main-spec spec
我修改了测试套件规范,以将main-是:LibSpec.hs文件
test-suite spec
default-language:Haskell2010
ghc-options :-Wall
类型:exitcode-stdio-1.0
hs-source-dirs:test
main-is:LibSpec.hs
build-depends:base
, chapterexercises
,hspec
,QuickCheck
stack ghci --test
请注意,如果有一个单一的测试隋工作te并没有其他可执行文件。否则它会给你一个警告:
* * * * * * * *
加载的主要模块不明确。候选人是:
包`项目'组件exe:project-exe与main-is文件:T:\ project \app\Main.hs
软件包`项目'组件测试:项目测试用main-file:T:\project\test\Spec.hs
将被加载。您可以指定选择哪一个:
1)指定堆叠ghci的目标例如stack ghci project:exe:project-exe
2)指定主要内容stack ghci --main-is project:exe:project-exe
* * * * * * * *
在这种情况下,您必须使用
stack ghci --test chapterexercises:test:spec
没有 - test
堆栈将忽略测试。这就是为什么你不首先得到模糊性错误。
I'm trying to use stack to load my test-suite in ghci and have it load the QuickCheck and hspec dependency.
How can I do this?
I'm using the franklinchen template.
https://github.com/commercialhaskell/stack-templates/blob/master/franklinchen.hsfiles
I have tried
stack ghci spec
stack ghci test-suite
stack ghci --main-is spec
I modified the test-suite spec to target the main-is: LibSpec.hs file
test-suite spec
default-language: Haskell2010
ghc-options: -Wall
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: LibSpec.hs
build-depends: base
, chapterexercises
, hspec
, QuickCheck
stack ghci --test
Note that this will only work if there's a single test suite and no other executable. Otherwise it will give you a warning:
* * * * * * * * The main module to load is ambiguous. Candidates are: Package `project' component exe:project-exe with main-is file: T:\project\app\Main.hs Package `project' component test:project-test with main-is file: T:\project\test\Spec.hs None will be loaded. You can specify which one to pick by: 1) Specifying targets to stack ghci e.g. stack ghci project:exe:project-exe 2) Specifying what the main is e.g. stack ghci --main-is project:exe:project-exe * * * * * * * *
In this case you have to use
stack ghci --test chapterexercises:test:spec
Without --test
stack is going to ignore the tests. That's why you don't get the ambiguity error in the first place.
这篇关于Haskell Stack Ghci测试套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!