问题 Haskell Stack Ghci测试套件


我正在尝试使用堆栈在ghci中加载我的测试套件并让它加载QuickCheck和hspec依赖项。

我怎样才能做到这一点?

我正在使用franklinchen模板。
https://github.com/commercialhaskell/stack-templates/blob/master/franklinchen.hsfiles

我努力了
堆栈ghci规范
stack ghci测试套件
stack ghci --main-is spec

我修改了测试套件规范以定位main-is:LibSpec.hs文件

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

12824
2018-01-01 16:48


起源



答案:


stack ghci --test

请注意,这只有在有一个测试套件而没有其他可执行文件时才有效。否则它会给你一个警告:

* * * * * * * *
加载的主要模块是模糊的。候选人是:
打包`project'组件exe:project-exe with main-is file:T:\ project \ app \ Main.hs
包`project'组件测试:用main-is文件进行项目测试: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 堆栈将忽略测试。这就是为什么你不首先得到歧义错误。


13
2018-01-01 17:45



也: stack ghci --test :spec 是简写 stack ghci --test chapterexercises:test:spec - dcastro


答案:


stack ghci --test

请注意,这只有在有一个测试套件而没有其他可执行文件时才有效。否则它会给你一个警告:

* * * * * * * *
加载的主要模块是模糊的。候选人是:
打包`project'组件exe:project-exe with main-is file:T:\ project \ app \ Main.hs
包`project'组件测试:用main-is文件进行项目测试: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 堆栈将忽略测试。这就是为什么你不首先得到歧义错误。


13
2018-01-01 17:45



也: stack ghci --test :spec 是简写 stack ghci --test chapterexercises:test:spec - dcastro