You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

中断cabal test后QuickCheck测试进程仍运行,是配置问题还是特性?

Cabal与QuickCheck组合下中断测试后残留失控进程的问题

以下是用于模拟永不终止测试的示例代码:

module Main where

import Control.Monad (unless)
import System.Exit (exitFailure)
import Test.QuickCheck

main :: IO ()
main = do
  result <- quickCheckResult neverEnding
  unless (isSuccess result) exitFailure

neverEnding :: [Int] -> Bool
neverEnding [] = True
neverEnding ls = let ls' = cycle ls
                 in 10 == sum ls'

在Cabal项目中,我通过以下命令运行该测试:

$ cabal test

执行命令后得到如下输出:

Build profile: -w ghc-9.4.8 -O1
In order, the following will be built (use -v for more details):
 - xnobar-0.1.0.0 (test:Test) (first run)
Preprocessing test suite 'Test' for xnobar-0.1.0.0..
Building test suite 'Test' for xnobar-0.1.0.0..
Running 1 test suites...
Test suite Test: RUNNING...

显然测试不会返回结果,因此我按下Ctrl+c中断。

但中断后,测试可执行文件仍在后台运行:

$ pidof Test
425742

过一会儿我也能通过电脑风扇声察觉到进程仍在运行。

因此我不得不手动杀死该进程:

kill $(pidof Test)

执行后得到如下结果:

Test suite Test: FAIL
Test suite logged to:
/path/to/Test.log
0 of 1 test suites (0 of 1 test cases) passed.

我不会故意编写永不终止的测试,但确实曾不小心写出过此类测试。这种脱离cabal test控制、持续运行的失控进程,在Haskell环境中完全不符合预期,感觉很不合理。

请问这是我的配置有误,还是Cabal与QuickCheck的组合本就如此,我只能接受?


内容的提问来源于stack exchange,提问作者Enlico

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 09:30:45