Skip to content

Commit

Permalink
Merge pull request #114 from getong/test_erlang_21
Browse files Browse the repository at this point in the history
Add OTP 21 support and CI coverage
  • Loading branch information
tolbrino authored Nov 1, 2018
2 parents e111c9c + a002358 commit 1d1c8a9
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ rel/example_project
.concrete/DEV_MODE
.rebar
logs
rebar3.crashdump
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
sudo: false
language: erlang
script: "make ci"
script:
- wget -c https://github.com/erlang/rebar3/releases/download/3.6.2/rebar3
- chmod +x rebar3
- REBAR3=./rebar3 make ci
otp_release:
- 21.1
- 20.3
- 20.2
- 20.1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REBAR3=$(shell which rebar3 || echo ./rebar3)
REBAR3 ?= rebar3

.PHONY: all clean clean_plt compile test doc dialyzer xref ci

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ processing is complete.
[hex]: https://hex.pm/packages/exometer_core
[hex version badge]: https://img.shields.io/hexpm/v/exometer_core.svg?style=flat-square
[hex license badge]: https://img.shields.io/hexpm/l/exometer_core.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-18--20-blue.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-18--21-blue.svg?style=flat-square
[build tool]: https://img.shields.io/badge/build%20tool-rebar3-orange.svg?style=flat-square


Expand Down
2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ processing is complete.
[hex]: https://hex.pm/packages/exometer_core
[hex version badge]: https://img.shields.io/hexpm/v/exometer_core.svg?style=flat-square
[hex license badge]: https://img.shields.io/hexpm/l/exometer_core.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-18--20-blue.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-18--21-blue.svg?style=flat-square
[build tool]: https://img.shields.io/badge/build%20tool-rebar3-orange.svg?style=flat-square


Expand Down
2 changes: 1 addition & 1 deletion doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -661,5 +661,5 @@ processing is complete.
[hex]: https://hex.pm/packages/exometer_core
[hex version badge]: https://img.shields.io/hexpm/v/exometer_core.svg?style=flat-square
[hex license badge]: https://img.shields.io/hexpm/l/exometer_core.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-18--20-blue.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-18--21-blue.svg?style=flat-square
[build tool]: https://img.shields.io/badge/build%20tool-rebar3-orange.svg?style=flat-square
8 changes: 8 additions & 0 deletions include/exometer.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@
-record(exometer_shared, {
name
}).

-ifdef(OTP_RELEASE). %% this implies 21 or higher
-define(EXCEPTION(Class, Reason, Stacktrace), Class:Reason:Stacktrace).
-define(GET_STACK(Stacktrace), Stacktrace).
-else.
-define(EXCEPTION(Class, Reason, _), Class:Reason).
-define(GET_STACK(_), erlang:get_stacktrace()).
-endif.
6 changes: 3 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

{deps,
[
{parse_trans, "3.2.0"},
{folsom, "0.8.5"},
{parse_trans, "3.3.0"},
{folsom, "0.8.7"},
{hut, "1.2.0"},
{setup, "2.0.2"}
]}.

{profiles,
[
{test, [{deps, [{meck, "0.8.9"}]}]},
{test, [{deps, [{meck, "0.8.12"}]}]},
{docs, [{deps, [{edown, "0.8.1"}]}]}
]}.

Expand Down
12 changes: 6 additions & 6 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{"1.1.0",
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.5">>},1},
{<<"folsom">>,{pkg,<<"folsom">>,<<"0.8.5">>},0},
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},1},
{<<"folsom">>,{pkg,<<"folsom">>,<<"0.8.7">>},0},
{<<"hut">>,{pkg,<<"hut">>,<<"1.2.0">>},0},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.2.0">>},0},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},0},
{<<"setup">>,{pkg,<<"setup">>,<<"2.0.2">>},0}]}.
[
{pkg_hash,[
{<<"bear">>, <<"E95FCA1627CD9E15BAF93CE0A52AFF16917BAF325F0EE65B88CD715376CD2344">>},
{<<"folsom">>, <<"94A027B56FE84FEED264F9B33CB4C6AC9A801FAD84B87DBDA0836CE83C3B8D69">>},
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>},
{<<"folsom">>, <<"A885F0AEEE4C84270954C88A55A5A473D6B2C7493E32FFDC5765412DD555A951">>},
{<<"hut">>, <<"0089DF0FAA2827C605BBADA88153F24FFF5EA7A4BE32ECF0250A7FDC2719CAFB">>},
{<<"parse_trans">>, <<"2ADFA4DAF80C14DC36F522CF190EB5C4EE3E28008FC6394397C16F62A26258C2">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"setup">>, <<"1203F4CDA11306C2E34434244576DED0A7BBFB0908D9A572356C809BD0CDF085">>}]}
].
Binary file removed rebar3
Binary file not shown.
8 changes: 4 additions & 4 deletions src/exometer_admin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,18 @@ handle_call({new_entry, Name, Type, Opts, AllowExisting} = _Req, _From, S) ->
Res = try exometer:create_entry(E1),
exometer_report:new_entry(E1)
catch
error:Error1 ->
?EXCEPTION(error, Error1, Stacktrace1) ->
?log(debug,
"ERROR create_entry(~p) :- ~p~n~p",
[E1, Error1, erlang:get_stacktrace()]),
[E1, Error1, ?GET_STACK(Stacktrace1)]),
erlang:error(Error1)
end,
{reply, Res, S}
end
catch
error:Error ->
?EXCEPTION(error, Error, Stacktrace) ->
?log(error, "~p -*-> error:~p~n~p~n",
[_Req, Error, erlang:get_stacktrace()]),
[_Req, Error, ?GET_STACK(Stacktrace)]),
{reply, {error, Error}, S}
end;
handle_call({repair_entry, Name}, _From, S) ->
Expand Down
6 changes: 5 additions & 1 deletion src/exometer_folsom_monitor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ monitor(FromMod, Callback) when is_atom(FromMod), is_atom(Callback) ->

%% @private
hook(Args) ->
Stack = try error(x) catch error:_ -> erlang:get_stacktrace() end,
Stack = try error(x)
catch
?EXCEPTION(error, _, Stacktrace) ->
?GET_STACK(Stacktrace)
end,
gen_server:cast(?MODULE, {hook, Args, Stack}).

%% @doc Start the server (called automatically by exometer).
Expand Down
4 changes: 2 additions & 2 deletions src/exometer_report.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1554,9 +1554,9 @@ unsubscribe_(#subscriber{key = #key{reporter = Reporter,
report_values(Found, #key{reporter = Reporter, extra = Extra} = Key) ->
try Reporter ! {exometer_report, Found, Extra}
catch
error:Reason ->
?EXCEPTION(error, Reason, Stacktrace) ->
?log(error, "~p~nKey = ~p~nTrace: ~p",
[Reason, Key, erlang:get_stacktrace()])
[Reason, Key, ?GET_STACK(Stacktrace)])
end.

retrieve_metric({Metric, Type, Enabled}, Acc) ->
Expand Down
2 changes: 1 addition & 1 deletion test/exometer_alias_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) ->
ok.

init_per_testcase(Case, Config) ->
init_per_testcase(_Case, Config) ->
{ok, StartedApps} = exometer_test_util:ensure_all_started(exometer_core),
[{started_apps, StartedApps} | Config].

Expand Down
4 changes: 2 additions & 2 deletions test/exometer_report_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ stop_started_apps(Config) ->
test_newentry(Config) ->
majority(fun test_newentry_/1, Config).

test_newentry_({cleanup, Config}) ->
test_newentry_({cleanup, _Config}) ->
restart_exometer_core();
test_newentry_(Config) ->
{ok, Info} = start_logger_and_reporter(test_udp, Config),
Expand Down Expand Up @@ -218,7 +218,7 @@ start_logger_and_reporter(Reporter, XArgs, Config) ->


test_subscription_race_regression(Config) ->
{ok, Info} = start_logger_and_reporter(brittle_reporter, Config),
{ok, _Info} = start_logger_and_reporter(brittle_reporter, Config),
ok = exometer:new([c,1], counter, []),
exometer_report:subscribe(brittle_reporter, {find,[c,'_']}, value, main, true),
LoggerPid = whereis(brittle_reporter),
Expand Down
2 changes: 1 addition & 1 deletion test/exometer_test_udp_reporter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ exometer_report(Metric, DataPoint, Extra, Value, #st{type_map = TypeMap,
{value, Value}]}, St),
{ok, St}.

exometer_report_bulk(Found, Extra, #st{} = St) ->
exometer_report_bulk(Found, _Extra, #st{} = St) ->
ok = send({report_bulk, Found}, St),
{ok, St}.

Expand Down

0 comments on commit 1d1c8a9

Please sign in to comment.