diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-07-11 11:16:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-11 11:16:33 -0400 |
commit | 403d33830732a6874931afb9c80bff4cb8e327f8 (patch) | |
tree | 124704feb94581f3420bb5fe4efbe9bb9f28e831 /test | |
parent | 8f6c13deada198f39cc4ac3b35e56a572ed143ba (diff) | |
parent | 0fa2b501f05e700a35c272f98f1ab976a5bd6170 (diff) |
Merge pull request #1262 from fishcakez/empty-plt
Handle empty PLT or app when using dialyzer
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_dialyzer_SUITE.erl | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/test/rebar_dialyzer_SUITE.erl b/test/rebar_dialyzer_SUITE.erl index 22a4894..e5d8c52 100644 --- a/test/rebar_dialyzer_SUITE.erl +++ b/test/rebar_dialyzer_SUITE.erl @@ -3,8 +3,14 @@ -export([suite/0, init_per_suite/1, end_per_suite/1, + init_per_group/2, + end_per_group/2, init_per_testcase/2, all/0, + groups/0, + empty_base_plt/1, + empty_app_plt/1, + empty_app_succ_typings/1, update_base_plt/1, update_app_plt/1, build_release_plt/1, @@ -23,6 +29,14 @@ init_per_suite(Config) -> end_per_suite(_Config) -> ok. +init_per_group(empty, Config) -> + [{base_plt_apps, []} | Config]; +init_per_group(_Group, Config) -> + [{base_plt_apps, [erts]} | Config]. + +end_per_group(_Group, _Config) -> + ok. + init_per_testcase(Testcase, Config) -> PrivDir = ?config(priv_dir, Config), Prefix = ec_cnv:to_list(Testcase), @@ -31,7 +45,7 @@ init_per_testcase(Testcase, Config) -> {plt_location, PrivDir}, {base_plt_prefix, BasePrefix}, {base_plt_location, PrivDir}, - {base_plt_apps, [erts]}], + {base_plt_apps, ?config(base_plt_apps, Config)}], Suffix = "_" ++ rebar_utils:otp_release() ++ "_plt", [{plt, filename:join(PrivDir, Prefix ++ Suffix)}, {base_plt, filename:join(PrivDir, BasePrefix ++ Suffix)}, @@ -39,7 +53,68 @@ init_per_testcase(Testcase, Config) -> rebar_test_utils:init_rebar_state(Config)]. all() -> - [update_base_plt, update_app_plt, build_release_plt, plt_apps_option]. + [{group, empty}, {group, build_and_check}, {group, update}]. + +groups() -> + [{empty, [empty_base_plt, empty_app_plt, empty_app_succ_typings]}, + {build_and_check, [build_release_plt, plt_apps_option]}, + {update, [update_base_plt, update_app_plt]}]. + +empty_base_plt(Config) -> + AppDir = ?config(apps, Config), + RebarConfig = ?config(rebar_config, Config), + BasePlt = ?config(base_plt, Config), + Plt = ?config(plt, Config), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [erts]), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["dialyzer"], + {ok, [{app, Name}]}), + + {ok, BasePltFiles} = plt_files(BasePlt), + ?assertEqual([], BasePltFiles), + + ErtsFiles = erts_files(), + {ok, PltFiles} = plt_files(Plt), + ?assertEqual(ErtsFiles, PltFiles), + + ok. + +empty_app_plt(Config) -> + AppDir = ?config(apps, Config), + RebarConfig = ?config(rebar_config, Config), + BasePlt = ?config(base_plt, Config), + Plt = ?config(plt, Config), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, []), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["dialyzer"], + {ok, [{app, Name}]}), + + {ok, BasePltFiles} = plt_files(BasePlt), + ?assertEqual([], BasePltFiles), + + {ok, PltFiles} = plt_files(Plt), + ?assertEqual([], PltFiles), + + ok. + +empty_app_succ_typings(Config) -> + AppDir = ?config(apps, Config), + RebarConfig = ?config(rebar_config, Config), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_empty_app(AppDir, Name, Vsn, []), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["dialyzer"], + {ok, [{app, Name}]}), + + ok. update_base_plt(Config) -> AppDir = ?config(apps, Config), |