Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Port no diff all option

  • Loading branch information...
commit c7a978165a1f77013a98b4e1695a5c196d6b67d0 1 parent d8a6bab
Gianfranco authored
Showing with 12 additions and 13 deletions.
  1. +8 −10 src/frame_axiom.erl
  2. +4 −3 test/frame_axiom_tests.erl
View
18 src/frame_axiom.erl
@@ -57,6 +57,8 @@ snapshot(Ets,{ets,all}) ->
snapshot(Ets,{ets,Options}) when is_list(Options) ->
lists:foldl(fun(Option,EtsAcc) -> snapshot(EtsAcc,ets,Option)
end,Ets,Options);
+snapshot(Ets,{port,all}) ->
+ snapshot(Ets,{port,all(port)});
snapshot(Ets,{port,Options}) when is_list(Options) ->
lists:foldl(fun(Option,EtsAcc) -> snapshot(EtsAcc,port,Option)
end,Ets,Options);
@@ -65,10 +67,6 @@ snapshot(Ets,ets) ->
Existing = ets:all(),
ets:insert(Ets,{ets,Existing}),
Ets;
-snapshot(Ets,port) ->
- Existing = erlang:ports(),
- ets:insert(Ets,{port,Existing}),
- Ets;
snapshot(Ets,{dir,Path}) ->
Structure = collect(false,Path),
ets:insert(Ets,{{dir,Path},Structure}),
@@ -165,6 +163,8 @@ diff(Ets,{ets,all}) ->
diff(Ets,{ets,Options}) when is_list(Options) ->
lists:foldl(fun(Option,Res) -> Res++diff(Ets,ets,Option)
end,[],Options);
+diff(Ets,{port,all}) ->
+ diff(Ets,{port,all(port)});
diff(Ets,{port,Options}) when is_list(Options) ->
lists:foldl(fun(Option,Res) -> Res++diff(Ets,port,Option)
end,[],Options);
@@ -174,11 +174,6 @@ diff(Ets,ets) ->
[{ets,Recorded}] = ets:lookup(Ets,ets),
{Created,Deleted} = split(created,deleted,Current,Recorded),
Created++Deleted;
-diff(Ets,port) ->
- Ports = erlang:ports(),
- [{port,Recorded}] = ets:lookup(Ets,port),
- {Opened,Closed} = split(opened,closed,Ports,Recorded),
- Opened++Closed;
diff(Ets,{dir,Path}) ->
Current = collect(false,Path),
[{{dir,Path},Recorded}] = ets:lookup(Ets,{dir,Path}),
@@ -307,7 +302,10 @@ all(process) ->
all(application) ->
[loaded,unloaded,started,stopped];
all(ets) ->
- [creation,deletion].
+ [creation,deletion];
+all(port) ->
+ [opened,closed].
+
collect(ExactP,Path) ->
View
7 test/frame_axiom_tests.erl
@@ -233,9 +233,10 @@ ports_closing_diff_test() ->
erlang:port_close(P),
?assertEqual([{closed,P}],frame_axiom:diff(Ref,[{port,Options}])).
-ports_no_change_diff_test() ->
- Ref = frame_axiom:snapshot(port),
- ?assertEqual([],frame_axiom:diff(Ref,port)).
+ports_all_no_change_diff_test() ->
+ Options = all,
+ Ref = frame_axiom:snapshot([{port,Options}]),
+ ?assertEqual([],frame_axiom:diff(Ref,[{port,Options}])).
%% file system
%% ---------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.