中断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
相关产品推荐
相关产品推荐

