aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/asn1_test_lib.erl
diff options
context:
space:
mode:
authorAdam Lindberg <[email protected]>2012-02-16 15:51:37 +0100
committerAdam Lindberg <[email protected]>2012-02-29 14:42:22 +0100
commit9ec0a0babace0932d78accf7c10b237a32dc801c (patch)
tree2d4a8e515a13497611631b0ed6cd787341ace27b /lib/asn1/test/asn1_test_lib.erl
parent79d2f2878c950584e56258a3c34724d42a91c631 (diff)
downloadotp-9ec0a0babace0932d78accf7c10b237a32dc801c.tar.gz
otp-9ec0a0babace0932d78accf7c10b237a32dc801c.tar.bz2
otp-9ec0a0babace0932d78accf7c10b237a32dc801c.zip
[asn1] Refactor test cases and remove extra suites
Diffstat (limited to 'lib/asn1/test/asn1_test_lib.erl')
-rw-r--r--lib/asn1/test/asn1_test_lib.erl50
1 files changed, 47 insertions, 3 deletions
diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl
index 70e78c5197..96c04a9436 100644
--- a/lib/asn1/test/asn1_test_lib.erl
+++ b/lib/asn1/test/asn1_test_lib.erl
@@ -21,6 +21,7 @@
-export([compile/3]).
-export([compile_all/3]).
+-export([compile_erlang/3]).
-export([ticket_7407_compile/2,ticket_7407_code/1, ticket_7678/2,
ticket_7708/2, ticket_7763/1, ticket_7876/3]).
@@ -32,11 +33,54 @@ compile(File, Config, Options) -> compile_all([File], Config, Options).
compile_all(Files, Config, Options) ->
DataDir = ?config(data_dir, Config),
CaseDir = ?config(case_dir, Config),
- % TODO: Purge and load as well?
- [ok = asn1ct:compile(filename:join(DataDir, F),
- [{outdir, CaseDir}|Options]) || F <- Files],
+ [compile_file(filename:join(DataDir, F), [{outdir, CaseDir}|Options])
+ || F <- Files],
ok.
+compile_file(File, Options) ->
+ try
+ ok = asn1ct:compile(File, Options),
+ case should_load(File, Options) of
+ false ->
+ ok;
+ {module, Module} ->
+ code:purge(Module),
+ true = code:soft_purge(Module),
+ {module, Module} = code:load_file(Module)
+ end
+ catch
+ Class:Reason ->
+ erlang:error({compile_failed, {File, Options}, {Class, Reason}})
+ end.
+
+compile_erlang(Mod, Config, Options) ->
+ DataDir = ?config(data_dir, Config),
+ CaseDir = ?config(case_dir, Config),
+ M = list_to_atom(Mod),
+ {ok, M} = compile:file(filename:join(DataDir, Mod),
+ [{i, CaseDir}, {outdir, CaseDir}|Options]).
+
+should_load(File, Options) ->
+ should_load(File, lists:member(abs, Options),
+ proplists:lookup(inline, Options)).
+
+should_load(_File, true, _Inline) ->
+ false;
+should_load(_File, _Abs, {inline, Module}) when Module /= true ->
+ {module, Module};
+should_load(File, _Abs, _Inline) ->
+ {module, list_to_atom(strip_extension(filename:basename(File)))}.
+
+strip_extension(File) ->
+ strip_extension(File, filename:extension(File)).
+
+strip_extension(File, "") ->
+ File;
+strip_extension(File, Ext) when Ext == ".asn"; Ext == ".set"; Ext == ".asn1"->
+ strip_extension(filename:rootname(File));
+strip_extension(File, _Ext) ->
+ File.
+
ticket_7407_compile(Config,Option) ->
?line DataDir = ?config(data_dir,Config),