diff options
author | Hans Bolinder <[email protected]> | 2017-04-11 13:06:50 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-04-13 12:31:10 +0200 |
commit | 3dd15a193e4a5aea1dd100d6a4e5ad3401334dfe (patch) | |
tree | 046f4e45402367604704099ab7638d8f64b7e87e /lib/dialyzer/test | |
parent | 19e9249d960a5b15b4e222efdcb96efbe122853e (diff) | |
download | otp-3dd15a193e4a5aea1dd100d6a4e5ad3401334dfe.tar.gz otp-3dd15a193e4a5aea1dd100d6a4e5ad3401334dfe.tar.bz2 otp-3dd15a193e4a5aea1dd100d6a4e5ad3401334dfe.zip |
stdlib: Add checks of the dialyzer attribute to the linter
The same checks are also performed by the Dialyzer.
Diffstat (limited to 'lib/dialyzer/test')
-rw-r--r-- | lib/dialyzer/test/plt_SUITE.erl | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/lib/dialyzer/test/plt_SUITE.erl b/lib/dialyzer/test/plt_SUITE.erl index ba153c1c27..92c63bdb0c 100644 --- a/lib/dialyzer/test/plt_SUITE.erl +++ b/lib/dialyzer/test/plt_SUITE.erl @@ -259,26 +259,41 @@ remove_plt(Config) -> {init_plt, Plt}] ++ Opts), ok. +%% ERL-283, OTP-13979. As of OTP-14323 this test no longer does what +%% it is designed to do--the linter stops every attempt to run the +%% checks of Dialyzer's on bad dialyzer attributes. For the time +%% being, the linter's error message are checked instead. The test +%% needs to be updated when/if the Dialyzer can analyze Core Erlang +%% without compiling abstract code. bad_dialyzer_attr(Config) -> PrivDir = ?config(priv_dir, Config), - Plt = filename:join(PrivDir, "plt_bad_dialyzer_attr.plt"), + Source = lists:concat([dial, ".erl"]), + Filename = filename:join(PrivDir, Source), + ok = dialyzer_common:check_plt(PrivDir), + PltFilename = dialyzer_common:plt_file(PrivDir), + Opts = [{files, [Filename]}, + {check_plt, false}, + {from, src_code}, + {init_plt, PltFilename}], + Prog1 = <<"-module(dial). -dialyzer({no_return, [undef/0]}).">>, - {ok, Beam1} = compile(Config, Prog1, dial, []), + ok = file:write_file(Filename, Prog1), {dialyzer_error, - "Analysis failed with error:\n" - "Could not scan the following file(s):\n" - " Unknown function undef/0 in line " ++ _} = - (catch run_dialyzer(plt_build, [Beam1], [{output_plt, Plt}])), + "Analysis failed with error:\n" ++ Str1} = + (catch dialyzer:run(Opts)), + P1 = string:str(Str1, "dial.erl:2: function undef/0 undefined"), + true = P1 > 0, Prog2 = <<"-module(dial). -dialyzer({no_return, [{undef,1,2}]}).">>, - {ok, Beam2} = compile(Config, Prog2, dial, []), + ok = file:write_file(Filename, Prog2), {dialyzer_error, - "Analysis failed with error:\n" - "Could not scan the following file(s):\n" - " Bad function {undef,1,2} in line " ++ _} = - (catch run_dialyzer(plt_build, [Beam2], [{output_plt, Plt}])), + "Analysis failed with error:\n" ++ Str2} = + (catch dialyzer:run(Opts)), + P2 = string:str(Str2, "dial.erl:2: badly formed dialyzer " + "attribute: {no_return,{undef,1,2}}"), + true = P2 > 0, ok. |