Permalink
Browse files

Replacing ugly explicit spawns with named function

  • Loading branch information...
1 parent bd397dc commit 5ba0fafc31a03bd9783de8d4097fad80473bf819 Gianfranco committed Jun 30, 2011
Showing with 16 additions and 2 deletions.
  1. +16 −2 test/frame_axiom_tests.erl
View
@@ -30,13 +30,13 @@
process_creation_diff_test() ->
Options = [creation],
Ref = frame_axiom:snapshot([{process,Options}]),
- Pid = spawn_link(fun() -> receive _ -> ok end end),
+ Pid = synchronoulsy_start_a_process(),
?assertEqual([{created,Pid}],frame_axiom:diff(Ref,[{process,Options}])).
process_death_diff_test() ->
Options = [death],
process_flag(trap_exit,true),
- Pid = spawn_link(fun() -> receive _ -> ok end end),
+ Pid = synchronoulsy_start_a_process(),
Ref = frame_axiom:snapshot([{process,Options}]),
synchronoulsy_kill_process(Pid),
?assertEqual([{died,Pid}],frame_axiom:diff(Ref,[{process,Options}])).
@@ -324,6 +324,20 @@ synchronoulsy_start_named(Name) ->
end,
Pid.
+synchronoulsy_start_a_process() ->
+ SharedSecret = make_ref(),
+ Master = self(),
+ Pid = spawn_link(fun() ->
+ Master ! SharedSecret,
+ receive _ -> ok end
+ end),
+ receive
+ SharedSecret ->
+ ok
+ end,
+ Pid.
+
+
synchronoulsy_kill_process(Pid) ->
Pid ! die,
receive

0 comments on commit 5ba0faf

Please sign in to comment.