diff options
author | Joseph Wayne Norton <norton@alum.mit.edu> | 2014-03-01 15:36:44 -0600 |
---|---|---|
committer | Joseph Wayne Norton <norton@alum.mit.edu> | 2014-03-29 23:22:47 -0500 |
commit | def6b8c98d6426430bf9de23622ff7e5b35c89ba (patch) | |
tree | cb5ede559425c646e11bbc7597aac4f51c28b578 | |
parent | 47c089aa806653d826b8bc5f4b8dc29724af1da7 (diff) |
Add partial support for Erlang/OTP 17
Allow rebar to compile applications using Erlang/OTP 17 and older
versions. This patch only provides partial support since the rebar
tool itself must be compiled using an Erlang/OTP version that is older
than 17.
-rw-r--r-- | src/rebar_require_vsn.erl | 5 | ||||
-rw-r--r-- | test/rebar_require_vsn_tests.erl | 23 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/rebar_require_vsn.erl b/src/rebar_require_vsn.erl index 385f55c..af805c8 100644 --- a/src/rebar_require_vsn.erl +++ b/src/rebar_require_vsn.erl @@ -34,7 +34,8 @@ eunit/2]). %% for internal use only --export([info/2]). +-export([info/2, + version_tuple/2]). %% =================================================================== %% Public API @@ -110,7 +111,7 @@ check_versions(Config) -> end. version_tuple(OtpRelease, Type) -> - case re:run(OtpRelease, "R(\\d+)B?-?(\\d+)?", [{capture, all, list}]) of + case re:run(OtpRelease, "R?(\\d+)B?-?(\\d+)?", [{capture, all, list}]) of {match, [_Full, Maj, Min]} -> {list_to_integer(Maj), list_to_integer(Min)}; {match, [_Full, Maj]} -> diff --git a/test/rebar_require_vsn_tests.erl b/test/rebar_require_vsn_tests.erl new file mode 100644 index 0000000..2d3a1ec --- /dev/null +++ b/test/rebar_require_vsn_tests.erl @@ -0,0 +1,23 @@ +-module(rebar_require_vsn_tests). + +-compile(export_all). + +-include_lib("eunit/include/eunit.hrl"). + +version_tuple_test_() -> + [%% typical cases + ?_assert(rebar_require_vsn:version_tuple("R15B", "eunit") =:= {15, 0}), + ?_assert(rebar_require_vsn:version_tuple("R15B01", "eunit") =:= {15, 1}), + ?_assert(rebar_require_vsn:version_tuple("R15B02", "eunit") =:= {15, 2}), + ?_assert(rebar_require_vsn:version_tuple("R15B03-1", "eunit") =:= {15, 3}), + ?_assert(rebar_require_vsn:version_tuple("R15B03", "eunit") =:= {15, 3}), + ?_assert(rebar_require_vsn:version_tuple("R16B", "eunit") =:= {16, 0}), + ?_assert(rebar_require_vsn:version_tuple("R16B01", "eunit") =:= {16, 1}), + ?_assert(rebar_require_vsn:version_tuple("R16B02", "eunit") =:= {16, 2}), + ?_assert(rebar_require_vsn:version_tuple("R16B03", "eunit") =:= {16, 3}), + ?_assert(rebar_require_vsn:version_tuple("R16B03-1", "eunit") =:= {16, 3}), + ?_assert(rebar_require_vsn:version_tuple("17", "eunit") =:= {17, 0}), + %% error cases + ?_assertException(throw, rebar_abort, rebar_require_vsn:version_tuple("", "eunit")), + ?_assertException(throw, rebar_abort, rebar_require_vsn:version_tuple("abc", "eunit")) + ]. |