aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2014-09-09 14:15:02 +0200
committerHenrik Nord <[email protected]>2014-09-09 14:15:05 +0200
commitf551de9de308ae5f21adc0e59806eab39146da7d (patch)
tree257dc7950c41697368760f947f3918273368f8f8 /lib/dialyzer/test
parenta146b28e6b17dbd2cae9ef090e5950985ec9dfe9 (diff)
parent80095fe4ee85f7374757472897581b9943363417 (diff)
downloadotp-f551de9de308ae5f21adc0e59806eab39146da7d.tar.gz
otp-f551de9de308ae5f21adc0e59806eab39146da7d.tar.bz2
otp-f551de9de308ae5f21adc0e59806eab39146da7d.zip
Merge branch 'fishcakez/dialyzer_beam_opts' into maint
* fishcakez/dialyzer_beam_opts: Use compile options when dialyzing beam files
Diffstat (limited to 'lib/dialyzer/test')
-rw-r--r--lib/dialyzer/test/dialyzer_SUITE.erl39
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/dialyzer/test/dialyzer_SUITE.erl b/lib/dialyzer/test/dialyzer_SUITE.erl
index 1b62291a00..8507525597 100644
--- a/lib/dialyzer/test/dialyzer_SUITE.erl
+++ b/lib/dialyzer/test/dialyzer_SUITE.erl
@@ -30,12 +30,12 @@
-export([init_per_testcase/2, end_per_testcase/2]).
%% Test cases must be exported.
--export([app_test/1, appup_test/1]).
+-export([app_test/1, appup_test/1, beam_tests/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [app_test, appup_test].
+ [app_test, appup_test, beam_tests].
groups() ->
[].
@@ -75,3 +75,38 @@ app_test(Config) when is_list(Config) ->
%% Test that the .appup file does not contain any `basic' errors
appup_test(Config) when is_list(Config) ->
ok = ?t:appup_test(dialyzer).
+
+beam_tests(Config) when is_list(Config) ->
+ Prog = <<"
+ -module(no_auto_import).
+
+ %% Copied from erl_lint_SUITE.erl, clash6
+
+ -export([size/1]).
+
+ size([]) ->
+ 0;
+ size({N,_}) ->
+ N;
+ size([_|T]) ->
+ 1+size(T).
+ ">>,
+ Opts = [no_auto_import],
+ {ok, BeamFile} = compile(Config, Prog, no_auto_import, Opts),
+ [] = run_dialyzer([BeamFile]),
+ ok.
+
+compile(Config, Prog, Module, CompileOpts) ->
+ Source = lists:concat([Module, ".erl"]),
+ PrivDir = ?config(priv_dir,Config),
+ Filename = filename:join([PrivDir, Source]),
+ ok = file:write_file(Filename, Prog),
+ Opts = [{outdir, PrivDir}, debug_info | CompileOpts],
+ {ok, Module} = compile:file(Filename, Opts),
+ {ok, filename:join([PrivDir, lists:concat([Module, ".beam"])])}.
+
+run_dialyzer(Files) ->
+ dialyzer:run([{analysis_type, plt_build},
+ {files, Files},
+ {from, byte_code},
+ {check_plt, false}]).