Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redbug does not work in eunit #22

Open
e-shubin opened this issue Feb 4, 2014 · 2 comments
Open

redbug does not work in eunit #22

e-shubin opened this issue Feb 4, 2014 · 2 comments

Comments

@e-shubin
Copy link

e-shubin commented Feb 4, 2014

A simple eunit test case causes an error in redbug

rb_test() ->
    {_, _} = redbug:start("lists:sort->stack", [{print_file, "redbug.txt"}]),
    timer:sleep(2000),
    ?assertEqual([1,2,3], lists:sort([3,2,1])),
    redbug:stop().
=ERROR REPORT==== 4-Feb-2014::15:04:28 ===
Error in process <0.69.0> with exit value: {terminated,[{io,format,[<0.67.0>,"~s~n",["\n15:04:28 <0.65.0>({erlang,apply,2}) {lists,sort,[[3,2,1]]}"]],[]},{redbug,'-mk_outer/1-fun-2-',5,[{file,"redbug.erl"},{line,343}]},{redbug,'-wrap_print_fun/1-fun-0-',3,[{file,"redbug.erl"},{line... 

I works good if eunit is not used.
I would love to see redbug working in eunit tests.

@e-shubin
Copy link
Author

e-shubin commented Feb 4, 2014

It works though if I put a sleep before redbug:stop/0 call.

@massemanet
Copy link
Owner

seems there's something screwy in how eunit handles file:fwrite/3. I'll discuss this with the eunit people.
Since the below works, this is hopefully not a showstopper for you.

t_0_test() ->
  Filename = "redbug.txt",
  {_, _} = redbug:start("lists:sort->stack", [{print_file, Filename}]),
  [1,2,3] = lists:sort([3,2,1]),
  redbug:stop(),
  ?assertEqual(ok,ok).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants