aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-09-25 11:28:19 +0200
committerAnders Svensson <[email protected]>2013-12-01 16:38:51 +0100
commit8e819a7960a256b6c3b7bf5856c3f81b8df9ca7e (patch)
tree4992f7815af4e08e48351c8d4ee4293f03ba8197 /lib/diameter/test
parentec91114dc4f14d787eeb07d7332b8803298b575c (diff)
downloadotp-8e819a7960a256b6c3b7bf5856c3f81b8df9ca7e.tar.gz
otp-8e819a7960a256b6c3b7bf5856c3f81b8df9ca7e.tar.bz2
otp-8e819a7960a256b6c3b7bf5856c3f81b8df9ca7e.zip
Simplify and extend diameter_make interface
In particular, make codec/2 flexible as to what's generated, the formats (erl, hrl, parse, forms and beam) being passed in the options list and defaulting to [erl, hrl]. The 'parse' format is the internal format to which dictionaries are parsed, which can be manipulated by flatten/1 before being passed back to codec/2 or format/1. Remove the (undocumented) dict/1,2 since codec/2 now subsumes it with the 'parse' option.
Diffstat (limited to 'lib/diameter/test')
-rw-r--r--lib/diameter/test/diameter_compiler_SUITE.erl32
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl
index 66c671b52d..943cac1446 100644
--- a/lib/diameter/test/diameter_compiler_SUITE.erl
+++ b/lib/diameter/test/diameter_compiler_SUITE.erl
@@ -366,8 +366,8 @@ format(Mods, Bin) ->
{Dict, Dict} = {Dict, D}.
make(File, Opts) ->
- case diameter_make:codec(File, [return, debug | Opts]) of
- {ok, [_E,_H,_F,[_Vsn|Dict]]} ->
+ case diameter_make:codec(File, [parse, hrl, return | Opts]) of
+ {ok, [Dict, _]} ->
{ok, Dict};
{error, _} = E ->
E
@@ -408,20 +408,30 @@ generate(Config) ->
[] = ?util:run([{?MODULE, [generate, M, Bin, N, T]}
|| {E,N} <- Rs,
{ok, M} <- [norm(E)],
- T <- [erl, hrl, dict]]).
+ T <- [erl, hrl, parse, forms]]).
generate(Mods, Bin, N, Mode) ->
B = modify(Bin, Mods ++ [{"@name .*", "@name dict" ++ ?L(N)}]),
{ok, Dict} = make(B, []),
File = "dict" ++ integer_to_list(N),
- {_, ok} = {Dict, diameter_codegen:from_dict("dict",
- Dict,
- [{name, File},
- {prefix, "base"},
- debug],
- Mode)},
- Mode == erl
- andalso ({ok, _} = compile:file(File ++ ".erl", [return_errors])).
+ {_, ok} = {Dict, diameter_make:codec(Dict,
+ [{name, File},
+ {prefix, "base"},
+ Mode])},
+ generate(Mode, File, Dict).
+
+generate(erl, File, _) ->
+ {ok, _} = compile:file(File ++ ".erl", [return_errors]);
+
+generate(forms, File, _) ->
+ {ok, [_]} = file:consult(File ++ ".F");
+
+generate(parse, File, Dict) ->
+ {ok, [Dict]} = file:consult(File ++ ".D"), %% assert
+ {ok, [_]} = diameter_make:codec(Dict, [beam, return]);
+
+generate(hrl, _, _) ->
+ ok.
%% ===========================================================================