我有一个使用Stack(因此是Cabal)构建的Haskell项目,现在我有src目录和测试目录,但是我想把测试和源文件混合在一起,这意味着所有的东西都会进入src目录。
为此,我需要定义我的 tests
build-info源文件是指src中扩展名为.test.hs的文件。然而,似乎定义源文件的唯一选择就是 source-dirs
叠 hs-source-dirs
意思是说,我必须把 src
作为 source-dirs
,这似乎是错误的,因为它也在捕获正常的源文件。
这是我的package.yaml.的一部分。
tests:
myapp-test:
main: Main.hs
source-dirs: test
...
我希望它是这样的:
tests:
myapp-test:
main: Main.hs
source-files: src/**/*.test.hs
...
有没有类似的选项,比如source -files,或者其他的方式来实现?谢谢!我有一个Haskell项目,它是由一个Haskell文件组成的。
分开 src
和 tests
dir是惯例,但不是必须的。hs-source-dirs
默认为 .
.
Cabal可以自己找到所有的源文件,否则就会出现以下情况。extra-source-files
.
你的选择是在模块层面。exposed-modules
, other-modules
.你可以将它们用于库和可执行文件。
在你的 .cabal
文件。
executable <name>
每个可执行文件的条目。main-is
是指文件中含有 module Main where ...
.library <name>
每个图书馆。使用一个 test-suite <name>
每项测试应用都需要参赛。
type
是必须的(如 type: exitcode-stdio-1.0
).main-is
是测试文件。ghc-options: -main-is <your.hs>
main :: IO ()
main = hspec spec -- or: spec1 >> spec2
卡巴尔的用法。
cabal new-build
cabal new-test [<which test>]
cabal new-run <file without path>
深入 dist-newstyle
你会发现
x
目录t
目录.so
归档 l
目录链接:
*.cabal
, cabal/Cabal/doc/buildinfo-fields-reference.rst