aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools/test/syntax_tools_SUITE.erl
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2013-12-14 02:04:40 +0100
committerMagnus Lidén <[email protected]>2014-01-21 16:49:28 +0100
commitf5a460fc93ee006cb0f76b7ace224a1300976c33 (patch)
treeff5ef0c45f550e7ca5b1e5a19d2843b25ad3ea20 /lib/syntax_tools/test/syntax_tools_SUITE.erl
parent5360e3097fad1f05965d309b672720a864c02e55 (diff)
downloadotp-f5a460fc93ee006cb0f76b7ace224a1300976c33.tar.gz
otp-f5a460fc93ee006cb0f76b7ace224a1300976c33.tar.bz2
otp-f5a460fc93ee006cb0f76b7ace224a1300976c33.zip
Smoke test erl_syntax:revert/1
This tries to make bugs like 87156887b7d82a2db53f60441a4af87034cb8789 not happen again. The new test takes each file in the stdlib app, passes their forms through the erl_syntax representation, reverts them and compiles them.
Diffstat (limited to 'lib/syntax_tools/test/syntax_tools_SUITE.erl')
-rw-r--r--lib/syntax_tools/test/syntax_tools_SUITE.erl29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl
index fd381f0b25..9eef56bddb 100644
--- a/lib/syntax_tools/test/syntax_tools_SUITE.erl
+++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl
@@ -24,12 +24,12 @@
init_per_group/2,end_per_group/2]).
%% Test cases
--export([smoke_test/1]).
+-export([smoke_test/1,revert/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [smoke_test].
+ [smoke_test,revert].
groups() ->
[].
@@ -79,6 +79,31 @@ print_error_markers(F, File) ->
end.
+%% Read with erl_parse, wrap and revert with erl_syntax and check for equality.
+revert(Config) when is_list(Config) ->
+ Dog = ?t:timetrap(?t:minutes(12)),
+ Wc = filename:join([code:lib_dir("stdlib"),"src","*.erl"]),
+ Fs = filelib:wildcard(Wc),
+ Path = [filename:join(code:lib_dir(stdlib), "include"),
+ filename:join(code:lib_dir(kernel), "include")],
+ io:format("~p files\n", [length(Fs)]),
+ case p_run(fun (File) -> revert_file(File, Path) end, Fs) of
+ 0 -> ok;
+ N -> ?line ?t:fail({N,errors})
+ end,
+ ?line ?t:timetrap_cancel(Dog).
+
+revert_file(File, Path) ->
+ case epp:parse_file(File, Path, []) of
+ {ok,Fs0} ->
+ Fs1 = erl_syntax:form_list(Fs0),
+ Fs2 = erl_syntax_lib:map(fun (Node) -> Node end, Fs1),
+ Fs3 = erl_syntax:form_list_elements(Fs2),
+ Fs4 = [ erl_syntax:revert(Form) || Form <- Fs3 ],
+ {ok,_} = compile:forms(Fs4, [report,strong_validation]),
+ ok
+ end.
+
p_run(Test, List) ->
N = erlang:system_info(schedulers),
p_run_loop(Test, List, N, [], 0).