29
29
-define(privdir, "xref_SUITE_priv").
30
30
-define(copydir, "xref_SUITE_priv/datacopy").
32
-include("test_server.hrl").
32
-include_lib("test_server/include/test_server.hrl").
33
33
-define(format(S, A), ok).
34
34
-define(datadir, ?config(data_dir, Conf)).
35
35
-define(privdir, ?config(priv_dir, Conf)).
36
36
-define(copydir, ?config(copy_dir, Conf)).
39
-export([all/1, init/1, fini/1]).
39
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
40
init_per_group/2,end_per_group/2, init/1, fini/1]).
42
43
addrem/1, convert/1, intergraph/1, lines/1, loops/1,
43
44
no_data/1, modules/1]).
46
47
add/1, default/1, info/1, lib/1, read/1, read2/1, remove/1,
47
48
replace/1, update/1, deprecated/1, trycatch/1,
48
abstract_modules/1, fun_mfa/1, qlc/1]).
49
abstract_modules/1, fun_mfa/1, fun_mfa_r14/1,
50
fun_mfa_vars/1, qlc/1]).
51
53
analyze/1, basic/1, md/1, q/1, variables/1, unused_locals/1]).
54
56
format_error/1, otp_7423/1, otp_7831/1]).
56
58
-import(lists, [append/2, flatten/1, keysearch/3, member/2, sort/1, usort/1]).
69
71
-include_lib("tools/src/xref.hrl").
72
{conf, init, [xref, files, analyses, misc], fini}.
73
suite() -> [{ct_hooks,[ts_install_cth]}].
76
[{group, xref}, {group, files}, {group, analyses},
81
[addrem, convert, intergraph, lines, loops, no_data,
84
[add, default, info, lib, read, read2, remove, replace,
85
update, deprecated, trycatch, abstract_modules, fun_mfa,
86
fun_mfa_r14, fun_mfa_vars, qlc]},
88
[analyze, basic, md, q, variables, unused_locals]},
89
{misc, [], [format_error, otp_7423, otp_7831]}].
91
init_per_suite(Config) ->
94
end_per_suite(_Config) ->
97
init_per_group(_GroupName, Config) ->
100
end_per_group(_GroupName, Config) ->
74
104
init(Conf) when is_list(Conf) ->
75
105
DataDir = ?datadir,
1747
1772
?line ok = file:delete(Beam),
1775
%% Same as the previous test case, except that we use a BEAM file
1776
%% that was compiled by an R14 compiler to test backward compatibility.
1777
fun_mfa_r14(Conf) when is_list(Conf) ->
1778
Dir = ?config(data_dir, Conf),
1779
MFile = fname(Dir, "fun_mfa_r14"),
1782
{ok, _} = xref:start(s),
1783
{ok, A} = xref:add_module(s, MFile, {warnings,false}),
1784
{ok, [{{{A,t,0},{'$M_EXPR','$F_EXPR',0}},[7]},
1785
{{{A,t,0},{A,t,0}},[6]},
1786
{{{A,t1,0},{'$M_EXPR','$F_EXPR',0}},[11]},
1787
{{{A,t1,0},{A,t,0}},[10]},
1788
{{{A,t2,0},{A,t,0}},[14]},
1789
{{{A,t3,0},{A,t3,0}},[17]}]} =
1790
xref:q(s, "(Lin) E"),
1792
ok = check_state(s),
1797
%% fun M:F/A with varibles.
1798
fun_mfa_vars(Conf) when is_list(Conf) ->
1800
File = fname(Dir, "fun_mfa_vars.erl"),
1801
MFile = fname(Dir, "fun_mfa_vars"),
1802
Beam = fname(Dir, "fun_mfa_vars.beam"),
1803
Test = <<"-module(fun_mfa_vars).
1805
-export([t/1, t1/1, t2/3]).
1812
F = fun ?MODULE:Name/1,
1815
t2(Mod, Name, Arity) ->
1816
F = fun Mod:Name/Arity,
1820
F = fun ?MODULE:t/Arity,
1828
F = fun Mod:t/Arity,
1832
ok = file:write_file(File, Test),
1834
{ok, A} = compile:file(File, [report,debug_info,{outdir,Dir}]),
1835
{ok, _} = xref:start(s),
1836
{ok, A} = xref:add_module(s, MFile, {warnings,false}),
1837
{ok, [{{{A,t,1},{'$M_EXPR','$F_EXPR',2}},[7]},
1838
{{{A,t,1},{'$M_EXPR',bar,2}},[6]},
1839
{{{A,t1,1},{'$M_EXPR','$F_EXPR',1}},[11]},
1840
{{{A,t1,1},{A,'$F_EXPR',1}},[10]},
1841
{{{A,t2,3},{'$M_EXPR','$F_EXPR',-1}},[14]},
1842
{{{A,t2,3},{'$M_EXPR','$F_EXPR',1}},[15]},
1843
{{{A,t3,1},{'$M_EXPR','$F_EXPR',3}},[19]},
1844
{{{A,t3,1},{fun_mfa_vars,t,-1}},[18]},
1845
{{{A,t4,2},{'$M_EXPR','$F_EXPR',3}},[22,23]},
1846
{{{A,t5,2},{'$M_EXPR','$F_EXPR',0}},[27]},
1847
{{{A,t5,2},{'$M_EXPR',t,-1}},[26]}]} =
1848
xref:q(s, "(Lin) E"),
1850
ok = check_state(s),
1853
ok = file:delete(File),
1854
ok = file:delete(Beam),
1750
1857
qlc(suite) -> [];
1751
1858
qlc(doc) -> ["OTP-5195: A bug fix when using qlc:q/1,2."];
1752
1859
qlc(Conf) when is_list(Conf) ->