Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 阴谋集团输出被重定向但未生成_Testing_Haskell_Build_Cabal - Fatal编程技术网

Testing 阴谋集团输出被重定向但未生成

Testing 阴谋集团输出被重定向但未生成,testing,haskell,build,cabal,Testing,Haskell,Build,Cabal,我建立了一个相当简单的haskell项目,在我真正开始编码之前,我只想让框架与测试等一起工作。我在/src目录(其中/是项目的根目录)中有可执行文件的源文件,在/testsuite目录中有测试/testsuite包含一个名为testsuite.hs的简单测试文件,其中main=test.Framework.defautMain tests作为main的实现。问题是,当我跑步的时候 cabal clean && cabal configure --enable-tests &

我建立了一个相当简单的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.
当我没有指定
--启用测试时,构建工作正常。我的阴谋集团档案是:

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
Name:示例
版本:0.1
简介:简介
说明:
长描述。
许可证:GPL
许可证文件:许可证
作者:肖克
维护者:email@example.com
类别:发展
构建类型:简单
阴谋集团版本:>=1.8
测试套件测试
类型:exitcode-stdio-1.0
主要代码是:TestSuite.hs
构建取决于:基>=3&<5,
测试框架,
测试框架快速检查
--快速检查
Hs源目录:src,
测试套件
可执行示例
Main是:Main.hs
--其他模块:
构建取决于:基>=3&<5,
哈斯凯尔98
Hs源目录:src
Ghc选项:-墙

我禁用了QuickCheck,因为我目前没有使用(=>),这是我目前唯一需要的功能。剩下的应该是直截了当的。非常感谢您的帮助。

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

引自:

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


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

引自:

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


与Fedor建议的重命名
TestSuite
模块不同,您可以添加一个GHC选项,将主模块的名称设置到您的Cabal文件中:

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

显然,阴谋集团
main和GHC
main是不同的。我不知道用什么方法。

而不是像Fedor建议的那样重命名
TestSuite
模块,您可以添加一个GHC选项,将主模块的名称设置到您的Cabal文件中:

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

显然,阴谋集团
main和GHC
main是不同的。我不知道用什么方式。

哇,这个要求真的需要在错误输出中突出显示。汇编几乎没有给出问题所在的线索。我以为用main is指出模块就足够了。@worldsayshi我在源代码(
MyProgram.lhs
)中明确给我的模块起了一个名字(
MyProgram.lhs
)之后就有了,但是如果我在ghc命令(
ghc-Wall-MyProgram-main是MyProgram.main
)中添加
-main是MyProgram.main,它确实生成可执行文件(
/myProgram
)。与您的观察相反,
-main是
,这是不够的。对于bare
ghc
来说,在我的情况下就足够了,也许,如果编译是由
cabal
完成的,就不会像您的情况那样顺利。哇,这个要求真的需要在错误输出中更加突出。汇编几乎没有给出问题所在的线索。我以为用main is指出模块就足够了。@worldsayshi我在源代码(
MyProgram.lhs
)中明确给我的模块起了一个名字(
MyProgram.lhs
)之后就有了,但是如果我在ghc命令(
ghc-Wall-MyProgram-main是MyProgram.main
)中添加
-main是MyProgram.main,它确实生成可执行文件(
/myProgram
)。与您的观察相反,
-main是
,这是不够的。对于bare
ghc
来说,在我的情况下就足够了,也许,如果编译是由
cabal
完成的,就像在你的情况下一样,它不会很顺利。