diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-05-24 20:43:04 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2016-05-24 20:43:04 -0400 |
commit | be79259e324e66ac2f948aed186474cb06a2ea85 (patch) | |
tree | 5a78ed6061e85189d08e871343a23ba8f1f04279 | |
parent | 124f121d38322a3db50458caeac47e84dccee45c (diff) |
Test support for OTP-19
-rw-r--r-- | rebar.config | 1 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 23 |
2 files changed, 18 insertions, 6 deletions
diff --git a/rebar.config b/rebar.config index ea5af27..7326b46 100644 --- a/rebar.config +++ b/rebar.config @@ -20,6 +20,7 @@ {"rebar/priv/templates/*", "_build/default/lib/"}]}. {erl_opts, [{platform_define, "^[0-9]+", namespaced_types}, + {platform_define, "^(19|2)", rand_only}, no_debug_info, warnings_as_errors]}. diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 8c2d36d..7e62109 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -7,6 +7,13 @@ create_config/2, create_config/3, package_app/3]). -export([create_random_name/1, create_random_vsn/0, write_src_file/2]). +%% Pick the right random module +-ifdef(rand_only). +-define(random, rand). +-else. +-define(random, random). +-endif. + %%%%%%%%%%%%%% %%% Public %%% %%%%%%%%%%%%%% @@ -126,20 +133,24 @@ create_config(_AppDir, ConfFilename, Contents) -> %% @doc Util to create a random variation of a given name. create_random_name(Name) -> random_seed(), - Name ++ erlang:integer_to_list(random:uniform(1000000)). + Name ++ erlang:integer_to_list(?random:uniform(1000000)). %% @doc Util to create a random variation of a given version. create_random_vsn() -> random_seed(), - lists:flatten([erlang:integer_to_list(random:uniform(100)), - ".", erlang:integer_to_list(random:uniform(100)), - ".", erlang:integer_to_list(random:uniform(100))]). + lists:flatten([erlang:integer_to_list(?random:uniform(100)), + ".", erlang:integer_to_list(?random:uniform(100)), + ".", erlang:integer_to_list(?random:uniform(100))]). +-ifdef(rand_only). +random_seed() -> + %% the rand module self-seeds + ok. +-else. random_seed() -> <<A:32, B:32, C:32>> = crypto:rand_bytes(12), random:seed({A,B,C}). - - +-endif. expand_deps(_, []) -> []; expand_deps(git, [{Name, Deps} | Rest]) -> |