diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_compile_SUITE.erl | 46 | ||||
-rw-r--r-- | test/rebar_install_deps_SUITE.erl | 34 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 2 |
3 files changed, 68 insertions, 14 deletions
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 7e72404..8ee8af4 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -19,7 +19,8 @@ delete_beam_if_source_deleted/1, checkout_priority/1, highest_version_of_pkg_dep/1, - parse_transform_test/1]). + parse_transform_test/1, + erl_first_files_test/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -46,7 +47,8 @@ all() -> build_all_srcdirs, recompile_when_hrl_changes, recompile_when_opts_change, dont_recompile_when_opts_dont_change, dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted, - deps_in_path, checkout_priority, highest_version_of_pkg_dep, parse_transform_test]. + deps_in_path, checkout_priority, highest_version_of_pkg_dep, + parse_transform_test, erl_first_files_test]. build_basic_app(Config) -> AppDir = ?config(apps, Config), @@ -441,3 +443,43 @@ parse_transform_test(Config) -> EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]), true = filelib:is_file(filename:join([EbinDir, "pascal.beam"])). + +erl_first_files_test(Config) -> + AppDir = ?config(apps, Config), + RebarConfig = [{erl_opts, [{parse_transform, mark_time}]}, + {erl_first_files, ["src/mark_time.erl", + "src/b.erl", + "src/d.erl", + "src/a.erl"]}], + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + rebar_test_utils:write_src_file(AppDir, "a.erl"), + rebar_test_utils:write_src_file(AppDir, "b.erl"), + rebar_test_utils:write_src_file(AppDir, "d.erl"), + rebar_test_utils:write_src_file(AppDir, "e.erl"), + + ExtraSrc = <<"-module(mark_time). " + "-export([parse_transform/2]). " + "parse_transform([Form={attribute,_,module,Mod}|Forms], Options) -> " + " [Form, {attribute,1,number, os:timestamp()} | Forms];" + "parse_transform([Form|Forms], Options) -> " + " [Form | parse_transform(Forms, Options)].">>, + + ok = file:write_file(filename:join([AppDir, "src", "mark_time.erl"]), ExtraSrc), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}), + + EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]), + true = filelib:is_file(filename:join([EbinDir, "mark_time.beam"])), + + code:load_abs(filename:join([EbinDir, "a"])), + code:load_abs(filename:join([EbinDir, "b"])), + code:load_abs(filename:join([EbinDir, "d"])), + code:load_abs(filename:join([EbinDir, "e"])), + A = proplists:get_value(number, a:module_info(attributes)), + B = proplists:get_value(number, b:module_info(attributes)), + D = proplists:get_value(number, d:module_info(attributes)), + E = proplists:get_value(number, e:module_info(attributes)), + ?assertEqual([B,D,A,E], lists:sort([A,B,D,E])). diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl index d1a1118..dca6308 100644 --- a/test/rebar_install_deps_SUITE.erl +++ b/test/rebar_install_deps_SUITE.erl @@ -48,10 +48,10 @@ end_per_testcase(_, Config) -> Config. format_expected_deps(Deps) -> - [case Dep of - {N,V} -> {dep, N, V}; - N -> {dep, N} - end || Dep <- Deps]. + lists:append([case Dep of + {N,V} -> [{dep, N, V}, {lock, N, V}]; + N -> [{dep, N}, {lock, N}] + end || Dep <- Deps]). %% format: %% {Spec, @@ -200,7 +200,7 @@ circular_skip(Config) -> run(Config). fail_conflict(Config) -> {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), rebar_test_utils:run_and_check( - Config, RebarConfig, ["install_deps"], ?config(expect, Config) + Config, RebarConfig, ["lock"], ?config(expect, Config) ), check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)). @@ -209,7 +209,7 @@ default_profile(Config) -> AppDir = ?config(apps, Config), {ok, Apps} = Expect = ?config(expect, Config), rebar_test_utils:run_and_check( - Config, RebarConfig, ["as", "profile", "install_deps"], Expect + Config, RebarConfig, ["as", "profile", "lock"], Expect ), check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)), BuildDir = filename:join([AppDir, "_build"]), @@ -221,18 +221,30 @@ default_profile(Config) -> || {dep, App} <- Apps], %% A second run to another profile also links default to the right spot rebar_test_utils:run_and_check( - Config, RebarConfig, ["as", "other", "install_deps"], Expect + Config, RebarConfig, ["as", "other", "lock"], Expect ), [?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs file:read_file_info(filename:join([BuildDir, "other", "lib", App]))) || {dep, App} <- Apps]. nondefault_profile(Config) -> + %% The dependencies here are saved directly to the {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), AppDir = ?config(apps, Config), - {ok, Apps} = Expect = ?config(expect, Config), + {ok, AppLocks} = ?config(expect, Config), + try + rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "nondef", "lock"], {ok, AppLocks} + ), + error(generated_locks) + catch + error:generated_locks -> error(generated_locks); + _:_ -> ok + end, + Apps = [App || App = {dep, _} <- AppLocks], + Expect = {ok, Apps}, rebar_test_utils:run_and_check( - Config, RebarConfig, ["as", "nondef", "install_deps"], Expect + Config, RebarConfig, ["as", "nondef", "lock"], Expect ), check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)), BuildDir = filename:join([AppDir, "_build"]), @@ -244,7 +256,7 @@ nondefault_profile(Config) -> || {dep, App} <- Apps], %% A second run to another profile doesn't link dependencies rebar_test_utils:run_and_check( - Config, RebarConfig, ["as", "other", "install_deps"], Expect + Config, RebarConfig, ["as", "other", "lock"], Expect ), [?assertMatch({error, enoent}, file:read_file_info(filename:join([BuildDir, "default", "lib", App]))) @@ -254,7 +266,7 @@ nondefault_profile(Config) -> run(Config) -> {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), rebar_test_utils:run_and_check( - Config, RebarConfig, ["install_deps"], ?config(expect, Config) + Config, RebarConfig, ["lock"], ?config(expect, Config) ), check_warnings(warning_calls(), ?config(warnings, Config), ?config(deps_type, Config)). diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 9c181d8..e5de0a6 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -4,7 +4,7 @@ -export([init_rebar_state/1, init_rebar_state/2, run_and_check/4]). -export([expand_deps/2, flat_deps/1, flat_pkgdeps/1, top_level_deps/1]). -export([create_app/4, create_eunit_app/4, create_empty_app/4, create_config/2]). --export([create_random_name/1, create_random_vsn/0]). +-export([create_random_name/1, create_random_vsn/0, write_src_file/2]). %%%%%%%%%%%%%% %%% Public %%% |