我正在尝试测试我的项目,它使用了"data-binary-ieee754“和doctest。
我使用cabal dev而不是cabal来管理包依赖关系。我可以构建项目,但doctest似乎无法识别该包。
文档测试.cabal中的定义:
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-ieee754test/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.请告诉我如何正确完成此操作。谢谢。
发布于 2012-08-10 10:07:58
我自己找到了答案。
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"]发布于 2016-02-10 01:45:36
稍微更新一下这个答案,doctest现在允许您直接调用ghc选项。
您还可以加载沙箱包数据库并从cabal调用。
doctest [ "-package-db .cabal-sandbox/x86_64-linux-ghc-7.10.3-packages.conf.d"
, "-isrc"
, "src/<path-to-file>"]这为我解决了缺少包的问题。
https://stackoverflow.com/questions/11893915
复制相似问题