Skip to content

Commit 161b38c

Browse files
authored
Merge pull request #2965 from ThomasArts/xref-apps
Make xref recognize apps again
2 parents 56c955c + eab1fa4 commit 161b38c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

apps/rebar/src/rebar_prv_xref.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ prepare(State) ->
9797
rebar_state:get(State, xref_warnings, false)},
9898
{verbose, rebar_log:is_verbose(State)}]),
9999

100-
[{ok, _} = xref:add_directory(xref, Dir)
100+
[ {ok, _} = xref:add_application(xref, Dir, [{name, binary_to_atom(rebar_app_info:name(App))}])
101101
|| App <- rebar_state:project_apps(State),
102102
%% the directory may not exist in rare cases of a compile
103103
%% hook of a dep running xref prior to the full job being done
104-
Dir <- [rebar_app_info:ebin_dir(App)], filelib:is_dir(Dir)],
104+
Dir <- [rebar_app_info:out_dir(App)], filelib:is_dir(Dir)],
105105

106106
%% Get list of xref checks we want to run
107107
ConfXrefChecks = rebar_state:get(State, xref_checks,

apps/rebar/test/rebar_xref_SUITE.erl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
all/0,
1111
xref_test/1,
1212
xref_ignore_test/1,
13+
xref_queries_test/1,
1314
xref_dep_hook/1,
1415
xref_undef_behaviour/1]).
1516

@@ -39,6 +40,12 @@ init_per_testcase(xref_dep_hook, Config) ->
3940
,{global_rebar_dir, GlobalDir}
4041
,{root_dir, Dst}]),
4142
[{apps, Dst}, {state, State} | Config];
43+
init_per_testcase(xref_queries_test, Config) ->
44+
UpdConfig = rebar_test_utils:init_rebar_state(Config),
45+
AppDir = ?config(apps, UpdConfig),
46+
Src = filename:join([?config(data_dir, Config), "recursive", "apps"]),
47+
ok = rebar_file_utils:cp_r([Src], AppDir),
48+
[{apps, AppDir} | UpdConfig ];
4249
init_per_testcase(Case, Config) ->
4350
UpdConfig = rebar_test_utils:init_rebar_state(Config),
4451
AppDir = ?config(apps, UpdConfig),
@@ -61,7 +68,8 @@ end_per_testcase(_, _Config) ->
6168
ok.
6269

6370
all() ->
64-
[xref_test, xref_ignore_test, xref_dep_hook, xref_undef_behaviour].
71+
[xref_test, xref_ignore_test, xref_dep_hook, xref_undef_behaviour,
72+
xref_queries_test].
6573

6674
%% ===================================================================
6775
%% Test cases
@@ -75,6 +83,16 @@ xref_test(Config) ->
7583
Result = rebar3:run(rebar_state:new(State, RebarConfig, AppDir), ["xref"]),
7684
verify_results(xref_test, Name, Result).
7785

86+
xref_queries_test(Config) ->
87+
AppDir = ?config(apps, Config),
88+
State = ?config(state, Config),
89+
RebarConfig = [{erl_opts, [debug_info]},
90+
{xref_queries, [{"A", [rebar_issue1, rebar_issue2]},
91+
{"(Fun) rebar_issue1 -> rebar_issue2", []}
92+
]}],
93+
{ok, _} = rebar3:run(rebar_state:new(State, RebarConfig, AppDir), ["xref"]),
94+
ok.
95+
7896
xref_ignore_test(Config) ->
7997
AppDir = ?config(apps, Config),
8098
State = ?config(state, Config),

0 commit comments

Comments
 (0)