summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_utils.erl19
-rw-r--r--test/rebar_utils_SUITE.erl8
2 files changed, 20 insertions, 7 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 26125a3..c71808d 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -306,8 +306,8 @@ check_min_otp_version(undefined) ->
check_min_otp_version(MinOtpVersion) ->
%% Fully-qualify with ?MODULE so the function can be meck'd in rebar_utils_SUITE
OtpRelease = ?MODULE:otp_release(),
- {MinMajor, MinMinor} = split_version(MinOtpVersion),
- {OtpMajor, OtpMinor} = split_version(OtpRelease),
+ {MinMajor, MinMinor} = version_tuple(MinOtpVersion),
+ {OtpMajor, OtpMinor} = version_tuple(OtpRelease),
case {OtpMajor, OtpMinor} >= {MinMajor, MinMinor} of
true ->
@@ -341,11 +341,16 @@ abort_if_blacklisted(BlacklistedRegex, OtpRelease) ->
%% ====================================================================
%% Internal functions
%% ====================================================================
-
-split_version(Version) ->
- list_to_tuple(lists:map(
- fun(S) -> list_to_integer(S) end,
- string:tokens(Version, "."))).
+version_tuple(OtpRelease) ->
+ 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]} ->
+ {list_to_integer(Maj), 0};
+ nomatch ->
+ ?WARN("", []),
+ {0,0}
+ end.
otp_release() ->
otp_release1(erlang:system_info(otp_release)).
diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl
index d766af4..144b840 100644
--- a/test/rebar_utils_SUITE.erl
+++ b/test/rebar_utils_SUITE.erl
@@ -25,6 +25,7 @@
task_with_multiple_flags/1,
special_task_do/1,
valid_otp_version/1,
+ valid_old_format_otp_version/1,
valid_otp_version_equal/1,
invalid_otp_version/1,
nonblacklisted_otp_version/1,
@@ -65,6 +66,7 @@ groups() ->
task_with_multiple_flags,
special_task_do,
valid_otp_version,
+ valid_old_format_otp_version,
valid_otp_version_equal,
invalid_otp_version,
nonblacklisted_otp_version,
@@ -145,6 +147,12 @@ valid_otp_version(_Config) ->
rebar_utils:check_min_otp_version("42.3"),
meck:unload(rebar_utils).
+valid_old_format_otp_version(_Config) ->
+ meck:new(rebar_utils, [passthrough]),
+ meck:expect(rebar_utils, otp_release, fun() -> "R15B03-1" end),
+ rebar_utils:check_min_otp_version("R15"),
+ meck:unload(rebar_utils).
+
valid_otp_version_equal(_Config) ->
meck:new(rebar_utils, [passthrough]),
meck:expect(rebar_utils, otp_release, fun() -> "42.3" end),