Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replacing ugly explicit spawns with named function

  • Loading branch information...
commit 5ba0fafc31a03bd9783de8d4097fad80473bf819 1 parent bd397dc
Gianfranco authored
Showing with 16 additions and 2 deletions.
  1. +16 −2 test/frame_axiom_tests.erl
View
18 test/frame_axiom_tests.erl
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.