cabal 测试无法 link 它自己的对象
cabal test fails to link its own objects
我正在尝试将 detailed-0.9
测试套件添加到提供可执行文件的 cabal 包中。因此我补充说:
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 的 Haskell 平台,GHC 7.8.3 将 Cabal 锁定到 1.18.1.3。
今天我偶然发现了同样的问题。
我找到了以下解决方法:
添加
other-modules: Syntax.Name
你的 test-suite
声明。
我正在尝试将 detailed-0.9
测试套件添加到提供可执行文件的 cabal 包中。因此我补充说:
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 的 Haskell 平台,GHC 7.8.3 将 Cabal 锁定到 1.18.1.3。
今天我偶然发现了同样的问题。 我找到了以下解决方法:
添加
other-modules: Syntax.Name
你的 test-suite
声明。