I am using eunit for some simple tests and within a test have a need to
sleep for a couple of seconds, i.e. the test function flows something like
this:
func_test() ->
some erlang code...
wait_for_2_seconds(),
some more erlang code....
To implement the wait_for_2_seconds() I have tried
receive after 2000 -> ok end, and
timer:sleep(2000),
as well as writing a simple spin wait function that just does idle
recursive execution in place for 2 seconds.
All of the above basically result in my eunit test function just hanging
forever and the last line printed on screen is
met_fb:request_content_ban_test...*timed out*
where met_fb is the module under test and request_content_ban_test is the
test function.
The actual test function is
request_content_ban_test() ->
?debugFmt("~n~nTEST : request_content_ban", []),
ok = request_content_ban(2, 1, 1, 2, 1),
ok = request_content_ban(3, 1, 1, 3, 2),
% spin loop for 2 seconds
spin_loop(epoch_secs(), 2),
?debugFmt("~n~nTEST : get_content_to_review", []),
Now = epoch_secs(),
[2,3] = get_content_to_review(1, 1, Now - 120),
ok = request_content_ban(4, 1, 1, 9, 3),
[4] = get_content_to_review(1, 1, Now - 1).
Would appreciate any help in figuring out what is going on here.
Regards,
Amit
Older versions of eunit (before OTP R13B) used to have this
kind of problem. Which version are you using?
/Richard
________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
Seems like the default timeout for a single test is 5 seconds. I increased
it using the "timeout" test descriptor and things are OK now.
But I still don't understand why my erlang console should just hang after
the "met_fb:request_content_ban_test...*timed out*" message is printed.
Amit
Once I increased it using the "timeout" control specification, my test cases
went through.
Amit
It's the eunit frontend that hangs; it's still waiting for some message
from the test, and doesn't return to the shell. But as far as I know,
this only happens in versions before R13B.