From e3d32b10cc074f3f76973ffad7038b8786b9b951 Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Mon, 1 Jun 2015 12:44:13 +0200 Subject: Fixed two tests for windows 8.1 and added touch functionality --- test/rebar_compile_SUITE.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 8ee8af4..8dca46c 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -163,9 +163,10 @@ recompile_when_hrl_changes(Config) -> ModTime = [filelib:last_modified(filename:join([EbinDir, F])) || F <- Files, filename:extension(F) == ".beam"], + timer:sleep(1000), - os:cmd("touch " ++ HeaderFile), + rebar_file_utils:touch(HeaderFile), rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}), @@ -274,9 +275,9 @@ delete_beam_if_source_deleted(Config) -> rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}), EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]), - SrcDir = filename:join([AppDir, "_build", "default", "lib", Name, "src"]), + _SrcDir = filename:join([AppDir, "_build", "default", "lib", Name, "src"]), ?assert(filelib:is_regular(filename:join(EbinDir, "not_a_real_src_" ++ Name ++ ".beam"))), - file:delete(filename:join(SrcDir, "not_a_real_src_" ++ Name ++ ".erl")), + file:delete(filename:join([AppDir, "src", "not_a_real_src_" ++ Name ++ ".erl"])), rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}), @@ -307,6 +308,7 @@ deps_in_path(Config) -> ?assertEqual([], [Path || Path <- code:get_path(), {match, _} <- [re:run(Path, DepName)]]), %% Hope not to find pkg name in there + ?assertEqual([], [Path || Path <- code:get_path(), {match, _} <- [re:run(Path, PkgName)]]), %% Build things -- cgit v1.1 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') 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 473393a172b68b9263a43b8d6a77a135caf7deff Mon Sep 17 00:00:00 2001 From: "Viacheslav V. Kovalev" Date: Thu, 4 Jun 2015 23:08:27 +0300 Subject: Fix rebar_utils:sh on windows --- test/rebar_utils_SUITE.erl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl index e9b32e2..76af5dd 100644 --- a/test/rebar_utils_SUITE.erl +++ b/test/rebar_utils_SUITE.erl @@ -21,7 +21,8 @@ task_with_flag_with_trailing_comma/1, task_with_flag_with_commas/1, task_with_multiple_flags/1, - special_task_do/1]). + special_task_do/1, + sh_don_not_miss_messages/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -29,7 +30,8 @@ all() -> - [{group, args_to_tasks}]. + [{group, args_to_tasks}, + sh_don_not_miss_messages]. groups() -> [{args_to_tasks, [], [empty_arglist, @@ -118,3 +120,14 @@ special_task_do(_Config) -> "do", "bar,", "baz"]). +sh_don_not_miss_messages(_Config) -> + Source = "~nmain(_) ->~n io:format(\"donotmissme\").~n", + file:write_file("do_not_miss_messages", io_lib:format(Source,[])), + {ok, "donotmissme"} = rebar_utils:sh("escript do_not_miss_messages", []), + AnyMessageRemained = + receive + What -> What + after 100 -> + false + end, + AnyMessageRemained = false. \ No newline at end of file -- cgit v1.1 From 53831dc31b457c758578f65311e0679ac980709d Mon Sep 17 00:00:00 2001 From: Viacheslav Kovalev Date: Fri, 5 Jun 2015 14:51:51 +0300 Subject: Fix rebar_hooks_SUITE:run_hooks_for_plugins/1 Test required `touch` utility to present on user's machine. Remove this dependency. --- test/rebar_hooks_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/rebar_hooks_SUITE.erl b/test/rebar_hooks_SUITE.erl index ec5cc9a..85ca0e5 100644 --- a/test/rebar_hooks_SUITE.erl +++ b/test/rebar_hooks_SUITE.erl @@ -114,7 +114,7 @@ run_hooks_for_plugins(Config) -> rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), PluginName = rebar_test_utils:create_random_name("plugin1_"), - mock_git_resource:mock([{config, [{pre_hooks, [{compile, "touch randomfile"}]}]}]), + mock_git_resource:mock([{config, [{pre_hooks, [{compile, "echo whatsup > randomfile"}]}]}]), RConfFile = rebar_test_utils:create_config(AppDir, [{plugins, [ -- 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') 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 ++- test/rebar_utils_SUITE.erl | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'test') 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. diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl index 76af5dd..f04ab63 100644 --- a/test/rebar_utils_SUITE.erl +++ b/test/rebar_utils_SUITE.erl @@ -22,7 +22,7 @@ task_with_flag_with_commas/1, task_with_multiple_flags/1, special_task_do/1, - sh_don_not_miss_messages/1]). + sh_does_not_miss_messages/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -31,7 +31,7 @@ all() -> [{group, args_to_tasks}, - sh_don_not_miss_messages]. + sh_does_not_miss_messages]. groups() -> [{args_to_tasks, [], [empty_arglist, @@ -120,7 +120,7 @@ special_task_do(_Config) -> "do", "bar,", "baz"]). -sh_don_not_miss_messages(_Config) -> +sh_does_not_miss_messages(_Config) -> Source = "~nmain(_) ->~n io:format(\"donotmissme\").~n", file:write_file("do_not_miss_messages", io_lib:format(Source,[])), {ok, "donotmissme"} = rebar_utils:sh("escript do_not_miss_messages", []), @@ -130,4 +130,4 @@ sh_don_not_miss_messages(_Config) -> after 100 -> false end, - AnyMessageRemained = false. \ No newline at end of file + AnyMessageRemained = false. -- 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') 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') 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