From 701f66aab2ff3b4118f9f93dd336876b1096c414 Mon Sep 17 00:00:00 2001 From: Viacheslav Kovalev Date: Wed, 3 Jun 2015 16:36:40 +0300 Subject: Fix multi_app_default_dirs test on windows. Seed random with erlang:now() because os:timestamp precision is not enough on windows. --- test/rebar_test_utils.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/rebar_test_utils.erl') diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index e5de0a6..2f4d532 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -105,12 +105,12 @@ create_config(AppDir, Contents) -> %% @doc Util to create a random variation of a given name. create_random_name(Name) -> - random:seed(os:timestamp()), + random:seed(erlang:now()), Name ++ erlang:integer_to_list(random:uniform(1000000)). %% @doc Util to create a random variation of a given version. create_random_vsn() -> - random:seed(os:timestamp()), + random:seed(erlang:now()), lists:flatten([erlang:integer_to_list(random:uniform(100)), ".", erlang:integer_to_list(random:uniform(100)), ".", erlang:integer_to_list(random:uniform(100))]). -- cgit v1.1 From 4eaa21cd274ac69f13429a63b8b7f2ed446e6870 Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Tue, 16 Jun 2015 21:39:55 +0200 Subject: Fixed so that release tests now pass. Got all green tests. --- test/rebar_test_utils.erl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test/rebar_test_utils.erl') diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 2f4d532..b210bc2 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -214,6 +214,7 @@ check_results(AppDir, Expected) -> ?assertNotEqual(false, lists:keyfind(Name, 1, DepsNames)) ; ({dep, Name, Vsn}) -> ct:pal("Dep Name: ~p, Vsn: ~p", [Name, Vsn]), + ct:pal("DepNames: ~p~n", [DepsNames]), case lists:keyfind(Name, 1, DepsNames) of false -> error({dep_not_found, Name}); @@ -273,11 +274,28 @@ check_results(AppDir, Expected) -> LibDir = filename:join([ReleaseDir, Name, "lib"]), {ok, RelLibs} = file:list_dir(LibDir), + ct:pal("RelLibs: ~p~n", [RelLibs]), IsSymLinkFun = fun(X) -> ec_file:is_symlink(filename:join(LibDir, X)) end, - DevMode = lists:all(IsSymLinkFun, RelLibs), + IsDirFun = + fun(X) -> + filelib:is_dir(filename:join([LibDir, X])) + end, + DevMode = + case os:type() of + {unix, _} -> + lists:all(IsSymLinkFun, RelLibs); + {win32, _} -> + Bool = lists:all(IsDirFun, RelLibs), + case ExpectedDevMode of + true -> + Bool; + false -> + not Bool + end + end, ?assertEqual(ExpectedDevMode, DevMode), %% throws not_found if it doesn't exist -- cgit v1.1 From 44272e23b641a016b74edf0cb9849b0656e8f726 Mon Sep 17 00:00:00 2001 From: "Viacheslav V. Kovalev" Date: Fri, 26 Jun 2015 22:35:39 +0300 Subject: Some fixes after review --- test/rebar_test_utils.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/rebar_test_utils.erl') diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index b210bc2..639a293 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -105,7 +105,8 @@ create_config(AppDir, Contents) -> %% @doc Util to create a random variation of a given name. create_random_name(Name) -> - random:seed(erlang:now()), + <> = crypto:rand_bytes(12), + random:seed({A,B,C}), Name ++ erlang:integer_to_list(random:uniform(1000000)). %% @doc Util to create a random variation of a given version. -- cgit v1.1 From ebfdbc695ef8bf615ab28fba1d8c22752f21e1cd Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Fri, 26 Jun 2015 22:39:15 +0200 Subject: Fixed review comments --- test/rebar_test_utils.erl | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'test/rebar_test_utils.erl') diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 639a293..0c65cb2 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -215,7 +215,6 @@ check_results(AppDir, Expected) -> ?assertNotEqual(false, lists:keyfind(Name, 1, DepsNames)) ; ({dep, Name, Vsn}) -> ct:pal("Dep Name: ~p, Vsn: ~p", [Name, Vsn]), - ct:pal("DepNames: ~p~n", [DepsNames]), case lists:keyfind(Name, 1, DepsNames) of false -> error({dep_not_found, Name}); @@ -275,28 +274,11 @@ check_results(AppDir, Expected) -> LibDir = filename:join([ReleaseDir, Name, "lib"]), {ok, RelLibs} = file:list_dir(LibDir), - ct:pal("RelLibs: ~p~n", [RelLibs]), IsSymLinkFun = fun(X) -> ec_file:is_symlink(filename:join(LibDir, X)) end, - IsDirFun = - fun(X) -> - filelib:is_dir(filename:join([LibDir, X])) - end, - DevMode = - case os:type() of - {unix, _} -> - lists:all(IsSymLinkFun, RelLibs); - {win32, _} -> - Bool = lists:all(IsDirFun, RelLibs), - case ExpectedDevMode of - true -> - Bool; - false -> - not Bool - end - end, + DevMode = lists:all(IsSymLinkFun, RelLibs), ?assertEqual(ExpectedDevMode, DevMode), %% throws not_found if it doesn't exist -- cgit v1.1 From 99858f3b6902c4feb95620ce0125c52635bf8f00 Mon Sep 17 00:00:00 2001 From: "Viacheslav V. Kovalev" Date: Sun, 28 Jun 2015 00:20:26 +0300 Subject: Use same random seeding function for random_name and random_vsn --- test/rebar_test_utils.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/rebar_test_utils.erl') diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 0c65cb2..4943d4b 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -105,17 +105,22 @@ create_config(AppDir, Contents) -> %% @doc Util to create a random variation of a given name. create_random_name(Name) -> - <> = crypto:rand_bytes(12), - random:seed({A,B,C}), + random_seed(), Name ++ erlang:integer_to_list(random:uniform(1000000)). %% @doc Util to create a random variation of a given version. create_random_vsn() -> - random:seed(erlang:now()), + 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))]). +random_seed() -> + <> = crypto:rand_bytes(12), + random:seed({A,B,C}). + + + expand_deps(_, []) -> []; expand_deps(git, [{Name, Deps} | Rest]) -> Dep = {Name, ".*", {git, "https://example.org/user/"++Name++".git", "master"}}, -- cgit v1.1