繁体   English   中英

将HUnit与Cabal集成时出现问题

[英]Problems while integrating HUnit with Cabal

cabal install命令运行良好, cabal configure --enable-tests 但是,当我运行cabal build -j它不会编译:

Building MoodleLatex-0.1.0.0...
Preprocessing executable 'moddlelat' for MoodleLatex-0.1.0.0...
Preprocessing test suite 'Moodle-Tests' for MoodleLatex-0.1.0.0...
In-place registering Moodle-Tests-0.1.0.0...
[1 of 1] Compiling Main             ( dist/build/Moodle-TestsStub/Moodle-TestsStub-tmp/Moodle-TestsStub.hs, dist/build/Moodle-TestsStub/Moodle-TestsStub-tmp/Main.o )
Linking dist/build/Moodle-TestsStub/Moodle-TestsStub ...
/home/miki/exp/moodle/dist/build/libMoodle-Tests.a(Moodle.o):(.text+0x26): undefined reference to `MoodlzuHFs0eta1wVtKnH9dbfcoDT_MoodleziTypes_zdfShowMoodleVal_closure'
/home/miki/exp/moodle/dist/build/libMoodle-Tests.a(Moodle.o):(.text+0xd9): undefined reference to `MoodlzuHFs0eta1wVtKnH9dbfcoDT_MoodleziTypes_zdfShowMoodleVal_closure'
/home/miki/exp/moodle/dist/build/libMoodle-Tests.a(Moodle.o):(.text+0xeba): undefined reference to `MoodlzuHFs0eta1wVtKnH9dbfcoDT_MoodleziParser_parseExpr2_closure'
[..snip..]
/home/miki/exp/moodle/dist/build/libMoodle-Tests.a(Moodle.o):(.data+0x570): undefined reference to `MoodlzuHFs0eta1wVtKnH9dbfcoDT_MoodleziParser_parseExpr2_closure'
/home/miki/exp/moodle/dist/build/libMoodle-Tests.a(Moodle.o):(.data+0x578): undefined reference to `MoodlzuHFs0eta1wVtKnH9dbfcoDT_MoodleziParser_parseExpr9_closure'
/home/miki/exp/moodle/dist/build/libMoodle-Tests.a(Moodle.o):(.data+0x580): undefined reference to `MoodlzuHFs0eta1wVtKnH9dbfcoDT_MoodleziParser_zdwa1_closure'
collect2: error: ld returned 1 exit status

这是源目录的结构:

src
├── Main.hs
├── Moodle
│   ├── Parser.hs
│   ├── Translator.hs
│   └── Types.hs
└── Test
    └── Moodle.hs

这是我的Cabal文件(仅相关行):

name:                MoodleLatex
version:             0.1.0.0
category:            Text
build-type:          Simple
extra-source-files:  README.md
cabal-version:       >=1.10

executable moddlelat
  main-is:             Main.hs
  -- other-modules:
  other-extensions:    OverloadedStrings
  build-depends: base       >=4.8  && <4.9
               , scientific >=0.3  && <0.4
               , text       >=1.2  && <1.3
               , attoparsec >=0.13 && <0.14
  hs-source-dirs:      src
  default-language:    Haskell2010

Test-Suite Moodle-Tests
  type:          detailed-0.9
  test-module:   Test.Moodle
  build-depends: base       >=4.8  && <4.9
               , scientific >=0.3  && <0.4
               , text       >=1.2  && <1.3
               , attoparsec >=0.13 && <0.14
               , Cabal
               , HUnit
               , cabal-test-hunit
  hs-source-dirs:      src
  default-language:    Haskell2010

我按照cabal-test-hunit README中的步骤进行操作 我也想知道,是否有必要两次声明依赖项? 它不是很干。

编辑 :似乎找不到我的模块。 但是,如果我将MoodleLatex添加到build-depends项中, MoodleLatex遇到另一个错误:

Building MoodleLatex-0.1.0.0...
Preprocessing executable 'moddlelat' for MoodleLatex-0.1.0.0...
Preprocessing test suite 'Moodle-Tests' for MoodleLatex-0.1.0.0...
<command line>: cannot satisfy -package-id MoodleLatex-0.1.0.0-inplace

您应该将其他模块添加到other-modules字段。 如果您使用Stack进行构建,它会警告您需要指定哪些模块。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM