Skip to content
Browse files

More port transgression

  • Loading branch information...
1 parent 1f0d2bc commit d8a6bab05d1b5640c32859ee064e972222e514aa Gianfranco committed Jul 1, 2011
Showing with 14 additions and 3 deletions.
  1. +11 −1 src/frame_axiom.erl
  2. +3 −2 test/frame_axiom_tests.erl
View
12 src/frame_axiom.erl
@@ -137,6 +137,10 @@ snapshot(Ets,ets,deletion) ->
snapshot(Ets,port,opened) ->
Ports = erlang:ports(),
ets:insert(Ets,{{port,opened},Ports}),
+ Ets;
+snapshot(Ets,port,closed) ->
+ Ports = erlang:ports(),
+ ets:insert(Ets,{{port,closed},Ports}),
Ets.
@@ -280,7 +284,13 @@ diff(Ets,port,opened) ->
Current = erlang:ports(),
Key = {port,opened},
[{Key,Recorded}] = ets:lookup(Ets,Key),
- [{opened,P}||P<-Current,not lists:member(P,Recorded)].
+ [{opened,P}||P<-Current,not lists:member(P,Recorded)];
+diff(Ets,port,closed) ->
+ Current = erlang:ports(),
+ Key = {port,closed},
+ [{Key,Recorded}] = ets:lookup(Ets,Key),
+ [{closed,C}||C<-Recorded,not lists:member(C,Current)].
+
View
5 test/frame_axiom_tests.erl
@@ -227,10 +227,11 @@ ports_creation_diff_test() ->
erlang:port_close(P).
ports_closing_diff_test() ->
+ Options = [closed],
P = erlang:open_port({spawn,"cd"},[stream]),
- Ref = frame_axiom:snapshot(port),
+ Ref = frame_axiom:snapshot([{port,Options}]),
erlang:port_close(P),
- ?assertEqual([{closed,P}],frame_axiom:diff(Ref,port)).
+ ?assertEqual([{closed,P}],frame_axiom:diff(Ref,[{port,Options}])).
ports_no_change_diff_test() ->
Ref = frame_axiom:snapshot(port),

0 comments on commit d8a6bab

Please sign in to comment.
Something went wrong with that request. Please try again.