【问题标题】:Why cabal repl test loads src modules?为什么 cabal repl 测试加载 src 模块?
【发布时间】:2022-07-26 15:32:57
【问题描述】:

我正在尝试使用 cabal repl 调试测试并观察到奇怪的行为。

cabal repl 正在为应用程序代码工作。

cabal repl

但不适用于测试服:

cabal repl tests

失败:

Loaded GHCi configuration from /home/user/myapp/.ghci

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        MyApp.X
        MyApp.Y
        ...

src/MyApp/X.hs:8:1: error:
    Could not load module ‘Relude’
    It is a member of the hidden package ‘relude-1.0.0.1’.

myapp.cabal:

name:           myapp
version:        0.5.0
library
  exposed-modules:
      MyApp.X
      MyApp.Y
  hs-source-dirs:
      src

  build-depends:
      relude >=1.0.0.1


test-suite tests
  type: exitcode-stdio-1.0
  main-is: Driver.hs
  other-modules:
      MyApp.Test.X
  hs-source-dirs:
      test
  ghc-options: -rtsopts -threaded 
  build-depends:
      HUnit
    , base
    , myapp 
cabal --version
cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library 

由于某种原因,cabal repl 从 src 文件夹而不是从测试文件夹加载模块。测试套装不依赖于 relude 依赖。它是隐藏的测试服和 当然 ghc 失败了。


大学推荐的解决方法:

:set -package bytestring
:set -package tasty
:set -package envy
:set -package tasty-hunit
:set -itest
:set -package HUnit

import Tasty (defaultMain) -- this may fail, ignore it

【问题讨论】:

    标签: haskell cabal


    【解决方案1】:

    你试过cabal repl test:tests吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 2019-05-28
      相关资源
      最近更新 更多