summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_cover_SUITE.erl17
-rw-r--r--test/rebar_ct_SUITE.erl27
-rw-r--r--test/rebar_plugins_SUITE.erl28
-rw-r--r--test/rebar_test_utils.erl9
4 files changed, 74 insertions, 7 deletions
diff --git a/test/rebar_cover_SUITE.erl b/test/rebar_cover_SUITE.erl
index 2918123..8d6429d 100644
--- a/test/rebar_cover_SUITE.erl
+++ b/test/rebar_cover_SUITE.erl
@@ -7,6 +7,7 @@
all/0,
flag_coverdata_written/1,
config_coverdata_written/1,
+ config_coverdata_overridden_name_written/1,
basic_extra_src_dirs/1,
release_extra_src_dirs/1,
root_extra_src_dirs/1,
@@ -36,6 +37,7 @@ init_per_testcase(_, Config) ->
all() ->
[flag_coverdata_written, config_coverdata_written,
+ config_coverdata_overridden_name_written,
basic_extra_src_dirs, release_extra_src_dirs,
root_extra_src_dirs,
index_written,
@@ -73,6 +75,21 @@ config_coverdata_written(Config) ->
true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "eunit.coverdata"])).
+config_coverdata_overridden_name_written(Config) ->
+ AppDir = ?config(apps, Config),
+
+ Name = rebar_test_utils:create_random_name("cover_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{erl_opts, [{d, some_define}]}, {cover_enabled, true}],
+ rebar_test_utils:run_and_check(Config,
+ RebarConfig,
+ ["eunit", "--cover_export_name=test_name"],
+ {ok, [{app, Name}]}),
+
+ true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "test_name.coverdata"])).
+
basic_extra_src_dirs(Config) ->
AppDir = ?config(apps, Config),
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl
index d7094ec..15dc63e 100644
--- a/test/rebar_ct_SUITE.erl
+++ b/test/rebar_ct_SUITE.erl
@@ -49,6 +49,7 @@
cfg_cover_spec/1,
cfg_atom_suites/1,
cover_compiled/1,
+ cover_export_name/1,
misspecified_ct_opts/1,
misspecified_ct_compile_opts/1,
misspecified_ct_first_files/1,
@@ -121,7 +122,8 @@ groups() -> [{basic_app, [], [basic_app_default_dirs,
cmd_create_priv_dir,
cmd_include_dir,
cmd_sys_config]},
- {cover, [], [cover_compiled]}].
+ {cover, [], [cover_compiled,
+ cover_export_name]}].
init_per_group(basic_app, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_"),
@@ -1251,6 +1253,29 @@ cover_compiled(Config) ->
Mod = list_to_atom(Name),
{file, _} = cover:is_compiled(Mod).
+cover_export_name(Config) ->
+ State = ?config(result, Config),
+
+ Providers = rebar_state:providers(State),
+ Namespace = rebar_state:namespace(State),
+ CommandProvider = providers:get_provider(ct, Providers, Namespace),
+ GetOptSpec = providers:opts(CommandProvider),
+ {ok, GetOptResult} = getopt:parse(GetOptSpec, ["--cover", "--cover_export_name=export_name"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ Tests = rebar_prv_common_test:prepare_tests(NewState),
+ {ok, _} = rebar_prv_common_test:compile(NewState, Tests),
+ rebar_prv_common_test:maybe_write_coverdata(NewState),
+
+ Name = ?config(name, Config),
+ Mod = list_to_atom(Name),
+ {file, _} = cover:is_compiled(Mod),
+
+ Dir = rebar_dir:profile_dir(rebar_state:opts(NewState), [default, test]),
+ ct:pal("DIR ~s", [Dir]),
+ true = filelib:is_file(filename:join([Dir, "cover", "export_name.coverdata"])).
+
misspecified_ct_opts(Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_atom_suites_"),
diff --git a/test/rebar_plugins_SUITE.erl b/test/rebar_plugins_SUITE.erl
index a313683..2d74539 100644
--- a/test/rebar_plugins_SUITE.erl
+++ b/test/rebar_plugins_SUITE.erl
@@ -14,7 +14,8 @@
upgrade_project_plugin/1,
sub_app_plugins/1,
sub_app_plugin_overrides/1,
- project_plugins/1]).
+ project_plugins/1,
+ use_checkout_plugins/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -37,7 +38,7 @@ end_per_testcase(_, _Config) ->
all() ->
[compile_plugins, compile_global_plugins, complex_plugins, list, upgrade, upgrade_project_plugin,
- sub_app_plugins, sub_app_plugin_overrides, project_plugins].
+ sub_app_plugins, sub_app_plugin_overrides, project_plugins, use_checkout_plugins].
%% Tests that compiling a project installs and compiles the plugins of deps
compile_plugins(Config) ->
@@ -370,3 +371,26 @@ project_plugins(Config) ->
?assertEqual(length(Release), 2),
?assertEqual(length(Compile), 1).
+
+use_checkout_plugins(Config) ->
+ AppDir = ?config(apps, Config),
+
+ 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]),
+
+ PluginName = "checkedout",
+ CheckoutsDir = filename:join(AppDir, "_checkouts/checkedout"),
+ rebar_test_utils:create_plugin(CheckoutsDir, PluginName, "1.0.0", []),
+
+ RConfFile =
+ rebar_test_utils:create_config(AppDir,
+ [{deps, []},
+ {plugins, [list_to_atom(PluginName)]}]),
+ {ok, RConf} = file:consult(RConfFile),
+
+ %% Verify we can run the plugin
+ ?assertMatch({ok, _}, rebar_test_utils:run_and_check(
+ Config, RConf, ["checkedout"],
+ {ok, []}
+ )).
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl
index c1e8b62..b74aa2f 100644
--- a/test/rebar_test_utils.erl
+++ b/test/rebar_test_utils.erl
@@ -425,15 +425,16 @@ erl_src_file(Name) ->
plugin_src_file(Name) ->
io_lib:format("-module('~s').\n"
- "-export([init/1]).\n"
+ "-export([init/1, do/1]).\n"
"init(State) -> \n"
"Provider = providers:create([\n"
"{name, '~s'},\n"
"{module, '~s'}\n"
"]),\n"
- "{ok, rebar_state:add_provider(State, Provider)}.\n", [filename:basename(Name, ".erl"),
- filename:basename(Name, ".erl"),
- filename:basename(Name, ".erl")]).
+ "{ok, rebar_state:add_provider(State, Provider)}.\n"
+ "do(State) -> {ok, State}.\n", [filename:basename(Name, ".erl"),
+ filename:basename(Name, ".erl"),
+ filename:basename(Name, ".erl")]).
erl_eunitized_src_file(Name) ->
io_lib:format("-module('~s').\n"