我试图将一个detailed-0.9测试套件添加到一个提供可执行文件的阴谋包中。因此,我补充说:
test-suite igor2-test
type: detailed-0.9
hs-source-dirs: src
test-module: Igor2.Tests
build-depends: Cabal此包中没有库,但可执行文件使用相同的源树。在cabal test期间,链接失败:
Preprocessing test suite 'igor2-test' for igor2-0.7.1.3...
[1 of 5] Compiling Syntax.Name ( src/Syntax/Name.hs, dist/build/Syntax/Name.o )
... (more compiling)
[1 of 5] Compiling Syntax.Name ( src/Syntax/Name.hs, dist/build/Syntax/Name.p_o )
... (more compiling)
In-place registering igor2-test-0.7.1.3...
[1 of 1] Compiling Main ( dist/build/igor2-testStub/igor2-testStub-tmp/igor2-testStub.hs, dist/build/igor2-testStub/igor2-testStub-tmp/Main.o )
Linking dist/build/igor2-testStub/igor2-testStub ...
/full/path/to/igor2/dist/build/libigor2-test.a(Tests.o): In function `cd3z_info':
(.text+0x2d7): undefined reference to `igor2zmtestzm0zi7zi1zi3_SyntaxziName_arrowName3_closure'
... (more undefined references)
collect2: error: ld returned 1 exit status为什么会失败?在模块arrowName中定义了Syntax.Name函数,并编译了该模块。不过,它没有在测试模块中使用。
我还尝试将包转换为一个库,并将测试套件构建依赖于库。链接器错误继续进行。
这是OpenSuSE 13.1,GHC7.8.3中的Haskell平台,它将Cabal锁定为1.18.1.3。
发布于 2015-09-03 17:38:15
今天我无意中遇到了同样的问题。我找到了以下解决办法:
添加
other-modules: Syntax.Name
到您的test-suite声明。
https://stackoverflow.com/questions/28857275
复制相似问题