我正在尝试测试使用doctests的“data-binary-ieee754”的项目。
我使用cabal-dev而不是cabal来管理包依赖关系。 我可以构建项目,但是doctest似乎没有认识到这个包。
.cabal中的doctests定义:
test-suite doctests
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: doctests.hs
ghc-options: -Wall -threaded
build-depends: base,
doctest >= 0.7,
data-binary-ieee754
测试/ doctests.hs:
module Main where
import Test.DocTest
main :: IO ()
main = doctest ["src/Pattern.hs"]
cabal-dev test doctests
的错误消息是:
Running 1 test suites...
Test suite doctests: RUNNING...
src/Pattern.hs:13:8:
Could not find module `Data.Binary.IEEE754'
Use -v to see a list of the files searched for.
Test suite doctests: FAIL
Test suite logged to: dist/test/othello-0.1.0-doctests.log
0 of 1 test suites (0 of 1 test cases) passed.
我尝试向doctests.hs添加一些选项,比如
main = doctest ["--optghc=-Lcabal-dev/lib",
"--optghc=-packagedata-binary-ieee754",
"src/Pattern.hs"]
但结果是
Running 1 test suites...
Test suite doctests: RUNNING...
doctests: <command line>: cannot satisfy -package data-binary-ieee754
(use -v for more information)
Test suite doctests: FAIL
Test suite logged to: dist/test/othello-0.1.0-doctests.log
0 of 1 test suites (0 of 1 test cases) passed.
告诉我如何正确地做到这一点。感谢。
答案 0 :(得分:3)
我自己找到了答案。
http://hackage.haskell.org/trac/ghc/ticket/6133很有帮助。
main :: IO ()
main = doctest ["--optghc=-Lcabal-dev/lib",
"--optghc=-packagedata-binary-ieee754",
"--optghc=-package-conf=cabal-dev/packages-7.4.1.conf",
"src/Pattern.hs"]
答案 1 :(得分:0)
只是稍微更新一下这个答案,doctest现在允许你直接调用ghc选项 您还可以加载沙盒包数据库并从cabal调用。
doctest [ "-package-db .cabal-sandbox/x86_64-linux-ghc-7.10.3-packages.conf.d"
, "-isrc"
, "src/<path-to-file>"]
这为我解决了丢失的包裹问题。