使用 cabal 的 detailed-0.9 测试时出现 "Prelude.read: no parse" 错误

Getting "Prelude.read: no parse" error when using detailed-0.9 tests with cabal

我尝试遵循 this guide 以便使用 detailed-0.9 测试类型为 Haskell 包编写一些测试。阴谋集团文件是

Name:           bar
Version:        1.0
License:        BSD3
Cabal-Version:  >= 1.10
Build-Type:     Simple

Library
    exposed-modules:     Foo
    build-depends:       base >=4.9 && <4.10
    default-language:    Haskell2010

Test-Suite test-bar
    type:       detailed-0.9
    test-module: Bar
    build-depends: base, Cabal >= 1.9.2
    default-language:    Haskell2010

并且Bar.hs是

module Bar ( tests ) where

import Distribution.TestSuite

tests :: IO [Test]
tests = return [ Test succeeds, Test fails ]
  where
    succeeds = TestInstance
        { run = return $ Finished Pass
        , name = "succeeds"
        , tags = []
        , options = []
        , setOption = \_ _ -> Right succeeds
        }
    fails = TestInstance
        { run = return $ Finished $ Fail "Always fails!"
        , name = "fails"
        , tags = []
        , options = []
        , setOption = \_ _ -> Right fails
        }

然而,当我 运行 测试

cabal configure --enable-tests
cabal build
cabal test

我明白了

Preprocessing test suite 'test-bar' for bar-1.0...
[1 of 1] Compiling Main             ( dist/build/test-barStub/test-barStub-tmp/test-barStub.hs, dist/build/test-barStub/test-barStub-tmp/Main.dyn_o )
Linking dist/build/test-barStub/test-barStub ...
Running 1 test suites...
Test suite test-bar: RUNNING...
Prelude.read: no parse

this repository 中的代码也会发生这种情况。

使用 strace cabal test 我设法看到 cabal 试图打开的最后一个文件是 dist/test/cabal-test-1804289383846930886.log,它不存在。创建文件没有帮助。

detailed-0.9 测试类型是否仍处于试验阶段?我应该改用 exitcode-stdio-1.0 吗?

GHC 版本:8.0.1
阴谋集团版本:1.24.0.0

编辑: 即使我在 Bar.hs.

中设置 tests = return [],错误仍然存​​在

问题似乎与动态 link年龄有关。 Cabal 找不到测试的 .so。在我的例子中,将 link 添加到 dist/build/bar-1.0-1l0Xa8pRO0dDWU0quwEdrS-test-bar.test/libHSbar-1.0-1l0Xa8pRO0dDWU0quwEdrS-test-bar.test-ghc8.0.1.so 解决了问题,但文件名可能会更改。

备选方案是在配置包时使用 cabal configure --enable-tests --disable-shared(我在我的 cabal 配置中隐式使用 --enable-shared)。或者我可以破解一个脚本,在调用 cabal test.

之前将 LD_LIBRARY_PATH 设置为正确的值

编辑:已经有一个 pull request on github