Eunit超时不起作用

TP.*_*TP. 2 erlang unit-testing

我试图在文件夹中使用eunit运行所有单元测试,但似乎超时总是重置为5秒.

例如

模块:

-module(example).
-include_lib("eunit/include/eunit.hrl").

main_test() ->
    % sleep for 10 seconds
    ?assertEqual(true, begin timer:sleep(10000), true end).
Run Code Online (Sandbox Code Playgroud)

命令行:

Eshell V5.7.3  (abort with ^G)
1> c(example).
{ok,example}
2> eunit:test({timeout, 15, example}).
  Test passed.
ok
3> eunit:test({timeout, 15, {dir, "."}}).
example: main_test (module 'example')...*timed out*
undefined
=======================================================
  Failed: 0.  Skipped: 0.  Passed: 0.
One or more tests were cancelled.
error
Run Code Online (Sandbox Code Playgroud)

如你所见,运行{timeout, 15, example}但不是{timeout, 15, {dir, "."}}.有人有线索吗?

leg*_*cia 6

对我来说有意义:整个目录的超时可能与单个测试的超时无关.

我会写这样的测试:

main_test_() ->
    % sleep for 10 seconds
    {timeout, 15, ?_assertEqual(true, begin timer:sleep(10000), true end)}.
Run Code Online (Sandbox Code Playgroud)

(添加了下划线来创建测试表达式而不是测试本身;它都在eunit手册中.我认为不可能以任何其他方式在测试中指定超时.)