aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_util.erl
diff options
context:
space:
mode:
authorAnders Svensson <anders@erlang.org>2011-07-27 19:26:57 +0200
committerAnders Svensson <anders@erlang.org>2011-09-26 17:11:05 +0200
commitc70314ecb08697d0926c0e86e048cd22dab60068 (patch)
tree324267fd5a4512f65f3278e672987eebd4e5fecd /lib/diameter/test/diameter_util.erl
parent85272930ebdf97ba8cf65962da17e980403ef06c (diff)
downloadotp-c70314ecb08697d0926c0e86e048cd22dab60068.tar.gz
otp-c70314ecb08697d0926c0e86e048cd22dab60068.tar.bz2
otp-c70314ecb08697d0926c0e86e048cd22dab60068.zip
Move appup tests into app suite and use systools for both
Diffstat (limited to 'lib/diameter/test/diameter_util.erl')
-rw-r--r--lib/diameter/test/diameter_util.erl39
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl
index 93760a1c07..99f4fa1977 100644
--- a/lib/diameter/test/diameter_util.erl
+++ b/lib/diameter/test/diameter_util.erl
@@ -23,31 +23,38 @@
%% Utility functions.
%%
--export([appfile/1,
+-export([consult/2,
run/1,
fold/3,
foldl/3,
scramble/1,
ps/0]).
-%% appfile/1
+-define(L, atom_to_list).
+
+%% consult/2
%%
-%% Extract info from the app file of the named application.
-
-appfile(Name) ->
- appfile(code:lib_dir(Name, ebin), Name).
-
-appfile({error = E, Reason}, _) ->
- {E, {code, Reason}};
-appfile(Dir, Name) ->
- case file:consult(filename:join([Dir, atom_to_list(Name) ++ ".app"])) of
- {ok, [{application, Name, App}]} ->
- {ok, App};
- {ok, Huh} ->
- {error, {content, Huh}};
+%% Extract info from the app/appup file (presumably) of the named
+%% application.
+
+consult(Name, Suf)
+ when is_atom(Name), is_atom(Suf) ->
+ case code:lib_dir(Name, ebin) of
+ {error = E, Reason} ->
+ {E, {Name, Reason}};
+ Dir ->
+ consult(filename:join([Dir, ?L(Name) ++ "." ++ ?L(Suf)]))
+ end.
+
+consult(Path) ->
+ case file:consult(Path) of
+ {ok, Terms} ->
+ Terms;
{error, Reason} ->
- {error, {file, Reason}}
+ {error, {Path, Reason}}
end.
+%% Name/Path in the return value distinguish the errors and allow for
+%% a useful badmatch.
%% run/1
%%