ソースを参照

parse old format of OTP versions

pull/642/head
Tristan Sloughter 10年前
コミット
6e9df6cc57
2個のファイルの変更20行の追加7行の削除
  1. +12
    -7
      src/rebar_utils.erl
  2. +8
    -0
      test/rebar_utils_SUITE.erl

+ 12
- 7
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)).

+ 8
- 0
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),

読み込み中…
キャンセル
保存