我试图在我的.cabal配置中为我的项目HaskSplit
创建一个测试套件:
-- Initial HaskSplit.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: HaskSplit
version: 0.1.0.0
synopsis: Haskell Implementation of Shamir's Secret Sharing Scheme
-- description:
license: MIT
license-file: LICENSE
author:
maintainer:
-- copyright:
category: Security
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
executable HaskSplit
main-is: Main.hs
default-language: Haskell2010
-- other-modules:
other-extensions: TemplateHaskell, NoImplicitPrelude, RankNTypes, OverloadedStrings
build-depends: base >=4.6 && <4.7,
resourcet >=1.1 && <1.2,
bytestring >=0.10 && <0.11,
conduit-extra >=1.1 && <1.2,
vector >=0.10 && <0.11,
conduit >=1.1 && <1.2,
conduit-combinators >=0.2 && <0.3,
mono-traversable >=0.5 && <0.6,
safe >=0.3 && <0.4,
transformers >=0.3 && <0.4,
filepath >= 1.3,
directory >=1.2,
Glob >= 0.7.4,
errors >= 1.4,
optparse-applicative >= 0.8
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall -fno-warn-orphans
test-suite tests
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: tests
main-is: Test.hs
ghc-options: -Wall -fno-warn-orphans
build-depends: base == 4.*,
QuickCheck >=2.6 && <2.7,
test-framework-quickcheck2 >= 0.3.0.3,
HaskSplit
查看示例测试套件设置here,我注意到他们正在将自己的包指定为构建依赖模块之一。因此我做了同样的事情,因此我可以保留我的build-depends
列表,以便我的测试套件更短。
但是,当我在命令行中尝试cabal repl test:tests
时,我收到以下错误:
<command line>: cannot satisfy -package-id HaskSplit-0.1.0.0-inplace
我不太确定我在这里失踪了什么,有人可以帮帮我吗?它周围是否发生了循环依赖?或者我是否需要为构建创建我的包的库实例 - 依赖于工作?
谢谢!
答案 0 :(得分:9)
build-depends
部分只能包含库,而不能包含模块。我建议你在你的cabal文件中添加一个库。库的exposed-modules
部分应列出您的测试(或库的任何其他用户)可能需要引用的所有模块。
作为创建库的替代方法,您只需将所需的模块添加到测试套件部分的其他模块部分即可。但是,如果你想要包含很多模块,我认为库方法更好。
答案 1 :(得分:2)
经过一些调整之后,为了完整起见,这就是我所得到的:
-- Initial HaskSplit.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: HaskSplit
version: 0.1.0.0
synopsis: Haskell Implementation of Shamir's Secret Sharing Scheme
-- description:
license: MIT
license-file: LICENSE
author:
maintainer:
-- copyright:
category: Security
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
executable HaskSplit
main-is: Main.hs
default-language: Haskell2010
-- other-modules:
other-extensions: RankNTypes
build-depends: base >=4.6 && <4.7,
resourcet >=1.1 && <1.2,
bytestring >=0.10 && <0.11,
conduit-extra >=1.1 && <1.2,
conduit >=1.1 && <1.2,
conduit-combinators >=0.2 && <0.3,
mono-traversable >=0.5 && <0.6,
safe >=0.3 && <0.4,
transformers >=0.3 && <0.4,
filepath >= 1.3,
directory >=1.2,
Glob >= 0.7.4,
errors >= 1.4,
optparse-applicative >= 0.8,
random == 1.*,
HaskSplit
hs-source-dirs: src/exe
default-language: Haskell2010
ghc-options: -Wall -fno-warn-orphans
library
Exposed-modules: HaskSplit.Algorithm,
HaskSplit.Util,
FiniteField.GF256,
FiniteField.PGF256
default-language: Haskell2010
hs-source-dirs: src/lib
build-depends: base >=4.6 && <4.7,
vector >=0.10 && <0.11,
random == 1.*
test-suite tests
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: tests
main-is: Test.hs
other-extensions: TemplateHaskell
ghc-options: -Wall -fno-warn-orphans
build-depends: base == 4.*,
QuickCheck >=2.6 && <2.7,
test-framework-quickcheck2 >= 0.3.0.3,
HaskSplit