diff options
author | Paulo Oliveira <paulo.oliveira@miniclip.com> | 2015-08-14 01:01:41 +0100 |
---|---|---|
committer | Paulo <paulo@Paulos-MacBook-Pro.local> | 2015-08-21 00:20:01 +0100 |
commit | 69802f63120c7bc87ad94eddeb43e1285ca770f9 (patch) | |
tree | 5badd38fcf7687595f824c58f6a59ea4cdf28e25 /inttest | |
parent | 3239e746e794520f27e940293a687a2c099d0b11 (diff) | |
download | rebar-69802f63120c7bc87ad94eddeb43e1285ca770f9.tar.gz |
Allow behaviors defined inside xref_extra_path
Use case: xref'ing a module that defined behavior ranch_protocol was
exiting with
{'EXIT',{undef,[{ranch_protocol,behaviour_info, [callbacks],[]}
Diffstat (limited to 'inttest')
-rw-r--r-- | inttest/xref_behavior/gen_xref_behavior.erl | 9 | ||||
-rw-r--r-- | inttest/xref_behavior/rebar.config | 6 | ||||
-rw-r--r-- | inttest/xref_behavior/xref_behavior.erl | 10 | ||||
-rw-r--r-- | inttest/xref_behavior/xref_behavior_rt.erl | 32 |
4 files changed, 57 insertions, 0 deletions
diff --git a/inttest/xref_behavior/gen_xref_behavior.erl b/inttest/xref_behavior/gen_xref_behavior.erl new file mode 100644 index 0000000..9ac66d2 --- /dev/null +++ b/inttest/xref_behavior/gen_xref_behavior.erl @@ -0,0 +1,9 @@ +-module(gen_xref_behavior). + +-export([behaviour_info/1]). -ignore_xref([{behaviour_info, 1}]). + +behaviour_info(callbacks) -> + [{init,1}, {handle, 1}]; +behaviour_info(_Other) -> + undefined. + diff --git a/inttest/xref_behavior/rebar.config b/inttest/xref_behavior/rebar.config new file mode 100644 index 0000000..c2e5af6 --- /dev/null +++ b/inttest/xref_behavior/rebar.config @@ -0,0 +1,6 @@ +{xref_warnings, true}. + +{xref_checks, [undefined_function_calls, undefined_functions, + locals_not_used, exports_not_used, + deprecated_function_calls, deprecated_functions]}. + diff --git a/inttest/xref_behavior/xref_behavior.erl b/inttest/xref_behavior/xref_behavior.erl new file mode 100644 index 0000000..30b6959 --- /dev/null +++ b/inttest/xref_behavior/xref_behavior.erl @@ -0,0 +1,10 @@ +-module(xref_behavior). +-behavior(gen_xref_behavior). + +% behavior-defined callbacks don't require xref_ignore +-export([init/1, handle/1]). + +init(_Args) -> ok. + +handle(_Atom) -> next_event. + diff --git a/inttest/xref_behavior/xref_behavior_rt.erl b/inttest/xref_behavior/xref_behavior_rt.erl new file mode 100644 index 0000000..8536710 --- /dev/null +++ b/inttest/xref_behavior/xref_behavior_rt.erl @@ -0,0 +1,32 @@ +-module(xref_behavior_rt). + +-export([files/0, run/1]). + +files() -> + [ + {copy, "../../rebar", "rebar"}, + {copy, "rebar.config", "rebar.config"}, + {copy, "xref_behavior.erl", "src/xref_behavior.erl"}, + {copy, "gen_xref_behavior.erl", "src/gen_xref_behavior.erl"}, + {create, "ebin/xref_behavior.app", app(xref_behavior, + [xref_behavior, + gen_xref_behavior])} + ]. + +run(_Dir) -> + {ok, _} = retest_sh:run("./rebar compile", []), + {ok, _} = retest_sh:run("./rebar xref", []), + ok. + +%% +%% Generate the contents of a simple .app file +%% +app(Name, Modules) -> + App = {application, Name, + [{description, atom_to_list(Name)}, + {vsn, "1"}, + {modules, Modules}, + {registered, []}, + {applications, [kernel, stdlib]}]}, + io_lib:format("~p.\n", [App]). + |