Cabal输出被重定向但未生成

时间:2012-08-26 19:44:46

标签: testing haskell build cabal

我有一个相当简单的haskell项目设置,我只想让框架在我开始编码之前使用测试等等。我在/src目录中有可执行文件的源文件(其中/是项目的根目录),我的测试在/testsuite目录中。 /testsuite包含一个名为TestSuite.hs的简单测试文件,main = Test.Framework.defautMain tests作为main的实现。问题是,当我运行

cabal clean && cabal configure --enable-tests && cabal build

我收到了警告

output was redirected with -o, but no output will be generated because there is no main module.

当我没有指定--enable-tests时,构建工作正常。我的cabal文件是:

Name:                Example
Version:             0.1
Synopsis:            Synopsis
Description:
    Long description.
License:             GPL
License-File:        LICENSE
Author:              SeanK
Maintainer:          email@example.com
Category:            Development
Build-Type:          Simple
Cabal-Version:       >= 1.8

Test-Suite test
    Type:               exitcode-stdio-1.0
    Main-Is:            TestSuite.hs
    Build-Depends:      base >= 3 && < 5,
                        test-framework,
                        test-framework-quickcheck
                        -- QuickCheck
    Hs-Source-Dirs:     src,
                        testsuite

Executable example
    Main-Is:            Main.hs
    -- Other-Modules:       
    Build-Depends:      base >= 3 && < 5,
                        haskell98
    Hs-Source-Dirs:     src
    Ghc-Options:        -Wall

我已禁用QuickCheck因为我目前没有使用(==&gt;),这是我目前唯一需要的功能。其余的应该是直截了当的。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:16)

您应该将TestSuite.hs文件中的模块名称定义为Main,例如there

来自The Haskell 98 Report的引用:

  

Haskell程序是模块的集合,按照惯例,其中一个必须被称为Main,并且必须导出值main。

答案 1 :(得分:3)

而不是将TestSuite模块重命名为Fedor建议您可以添加GHC选项以将主模块的名称设置为您的Cabal文件:

Test-Suite testFedor
    ghc-options:    -main-is TestSuite

显然,Cabal main-is和GHC main-is是不同的。我不知道怎么做。