为什么在Cabal中对测试套件和可执行文件的指定有所不同?

时间:2018-11-18 19:11:52

标签: haskell cabal

我对Haskell软件包的hs-source-dirsother-modules组件如何指定test-suiteexecutable之间的区别感到困惑。

因为似乎有必要为executable重新指定我程序包的模块和源目录,而对于test则没有必要:

name:                   my-pkg

library
    exposed-modules:    My.Pkg,
                        My.Pkg.A
    other-modules:      My.Pkg.B 
    -- ...

executable myexe
    main-is:            myexe.hs
    hs-source-dirs:     ., cli
    other-modules:      My.Pkg,
                        My.Pkg.A,
                        My.Pkg.B
    build-depends:      base >=4.8.1.0 && <=4.12.0.0,
                        optparse-applicative >=0.11.0.2,
                        ansi-terminal >=0.6.2.3,
                        my-pkg

test-suite my-pkg-check
    type:               exitcode-stdio-1.0
    hs-source-dirs:     test
    main-is:            Check.hs
    build-depends:      base >=4.8.1.0 && <=4.12.0.0,
                        QuickCheck >=2.8,
                        my-pkg

所有这些都是必要的吗?省略了一些本可以让我简单拥有的东西

executable myexe
    main-is:            myexe.hs
    hs-source-dirs:     cli
    build-depends:      base >=4.8.1.0 && <=4.12.0.0,
                        optparse-applicative >=0.11.0.2,
                        ansi-terminal >=0.6.2.3,
                        my-pkg

executable一样test-suite


以上的部分目录结构:

├── My
│   ├── Pkg
│   │   ├── A.hs
│   │   └── B.hs
│   └── Pkg.hs
├── cli
│   └── enigma.hs
├── my-pkg.cabal
├── stack.yaml
├── test
│   ├── Check.hs
│   └── Test.hs

0 个答案:

没有答案
相关问题