eunit question

Amit Murthy amit.murthy@REDACTED
Sun Aug 16 12:02:38 CEST 2009


Hi,

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


More information about the erlang-questions mailing list