我是否必须重复测试配置中的所有依赖项?

时间:2015-04-27 09:35:40

标签: haskell cabal

这一次又一次让我烦恼,基本上如果我在cabal配置中创建test-suite,我将项目src文件夹添加到测试套件hs-source-dirs部分,并重复build-depends部分中的所有依赖项{1}}。典型项目可能如下所示:

-- in file "foo.cabal"
library
  build-depends: a, b, c
  exposed-modules: Foo, Bar
  hs-source-dirs: src

test-suite tests
  build-depends: foo, a, b, c
  hs-source-dirs: test

另一个选项是在测试套件src中加入hs-source-dirs

据我所知,它们都要求我在测试用例中指定所有构建依赖项。有办法解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

它应该按原样运行,但与cabal test

一起使用时有一个reported bug

总体而言,它似乎适用于cabal repl,但如果您尝试将测试文件加载到Could not find module ‘XYZ’ It is a member of the hidden package ‘XZY-[ver]’. Perhaps you need to add ‘XYZ’ to the build-depends in your .cabal file. Use -v to see a list of the files searched for. ,则可能会出现如下错误:

    <?php
    $item_query=mysql_query("SELECT * FROM items ") or die(mysql_error());
    while($run_item=mysql_fetch_array($item_query))
    {
        $itemid=$run_item['item_id'];
        $name=$run_item['productname'];
        echo "<br/>";
        echo "<a href='product.php?product=$userid'>$username</a>";
    }
?>

所以现在确实复制依赖项可能是一个好主意,但希望很快就能解决这个问题

相关问题