summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_ct_SUITE.erl698
-rw-r--r--test/rebar_dialyzer_SUITE.erl34
2 files changed, 568 insertions, 164 deletions
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl
index cdd3774..ac016b1 100644
--- a/test/rebar_ct_SUITE.erl
+++ b/test/rebar_ct_SUITE.erl
@@ -17,15 +17,40 @@
multi_suite/1,
all_suite/1,
single_dir_and_single_suite/1,
- symlinked_dir_overwritten_fix/1,
- data_dir_correct/1]).
+ data_dir_correct/1,
+ cmd_label/1,
+ cmd_config/1,
+ cmd_allow_user_terms/1,
+ cmd_logdir/1,
+ cmd_logopts/1,
+ cmd_verbosity/1,
+ cmd_repeat/1,
+ cmd_duration/1,
+ cmd_until/1,
+ cmd_force_stop/1,
+ cmd_basic_html/1,
+ cmd_stylesheet/1,
+ cmd_decrypt_key/1,
+ cmd_decrypt_file/1,
+ cmd_abort_if_missing_suites/1,
+ cmd_multiply_timetraps/1,
+ cmd_scale_timetraps/1,
+ cmd_create_priv_dir/1,
+ cfg_opts/1,
+ cfg_arbitrary_opts/1,
+ cfg_test_spec_filtered/1,
+ cfg_atom_suites/1]).
-include_lib("common_test/include/ct.hrl").
all() -> [{group, basic_app},
{group, multi_app},
{group, dirs_and_suites},
- {group, data_dirs}].
+ {group, data_dirs},
+ {group, ct_opts},
+ cfg_opts, cfg_arbitrary_opts,
+ cfg_test_spec_filtered,
+ cfg_atom_suites].
groups() -> [{basic_app, [], [basic_app_default_dirs,
basic_app_default_beams]},
@@ -39,9 +64,26 @@ groups() -> [{basic_app, [], [basic_app_default_dirs,
single_unmanaged_suite,
multi_suite,
all_suite,
- single_dir_and_single_suite,
- symlinked_dir_overwritten_fix]},
- {data_dirs, [], [data_dir_correct]}].
+ single_dir_and_single_suite]},
+ {data_dirs, [], [data_dir_correct]},
+ {ct_opts, [], [cmd_label,
+ cmd_config,
+ cmd_allow_user_terms,
+ cmd_logdir,
+ cmd_logopts,
+ cmd_verbosity,
+ cmd_repeat,
+ cmd_duration,
+ cmd_until,
+ cmd_force_stop,
+ cmd_basic_html,
+ cmd_stylesheet,
+ cmd_decrypt_key,
+ cmd_decrypt_file,
+ cmd_abort_if_missing_suites,
+ cmd_multiply_timetraps,
+ cmd_scale_timetraps,
+ cmd_create_priv_dir]}].
init_per_group(basic_app, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_"),
@@ -56,22 +98,14 @@ init_per_group(basic_app, Config) ->
ok = filelib:ensure_dir(Suite),
ok = file:write_file(Suite, test_suite(Name)),
- {ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "compile"], return),
+ {ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "lock"], return),
- LibDirs = rebar_dir:lib_dirs(State),
- State1 = rebar_app_discover:do(State, LibDirs),
-
- Providers = rebar_state:providers(State1),
- Namespace = rebar_state:namespace(State1),
- CommandProvider = providers:get_provider(ct, Providers, Namespace),
- GetOptSpec = providers:opts(CommandProvider),
- {ok, GetOptResult} = getopt:parse(GetOptSpec, []),
+ Tests = rebar_prv_common_test:prepare_tests(State),
+ {ok, NewState} = rebar_prv_common_test:compile(State, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- State2 = rebar_state:command_parsed_args(State1, GetOptResult),
-
- Result = rebar_prv_common_test:setup_ct(State2),
-
- [{result, Result}, {appnames, [Name]}|C];
+ [{result, Opts}, {appnames, [Name]}|C];
init_per_group(multi_app, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_"),
@@ -99,22 +133,14 @@ init_per_group(multi_app, Config) ->
ok = filelib:ensure_dir(Suite3),
ok = file:write_file(Suite3, test_suite("extras")),
- {ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "compile"], return),
+ {ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "lock"], return),
- LibDirs = rebar_dir:lib_dirs(State),
- State1 = rebar_app_discover:do(State, LibDirs),
+ Tests = rebar_prv_common_test:prepare_tests(State),
+ {ok, NewState} = rebar_prv_common_test:compile(State, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Providers = rebar_state:providers(State1),
- Namespace = rebar_state:namespace(State1),
- CommandProvider = providers:get_provider(ct, Providers, Namespace),
- GetOptSpec = providers:opts(CommandProvider),
- {ok, GetOptResult} = getopt:parse(GetOptSpec, []),
-
- State2 = rebar_state:command_parsed_args(State1, GetOptResult),
-
- Result = rebar_prv_common_test:setup_ct(State2),
-
- [{result, Result}, {appnames, [Name1, Name2]}|C];
+ [{result, Opts}, {appnames, [Name1, Name2]}|C];
init_per_group(dirs_and_suites, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_"),
@@ -142,7 +168,21 @@ init_per_group(dirs_and_suites, Config) ->
ok = filelib:ensure_dir(Suite3),
ok = file:write_file(Suite3, test_suite("extras")),
- [{appnames, [Name1, Name2]}|C];
+ {ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "lock"], return),
+
+ [{s, State}, {appnames, [Name1, Name2]}|C];
+init_per_group(ct_opts, Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_opts"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_opts_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ {ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "lock"], return),
+
+ [{result, State}|C];
init_per_group(_, Config) -> Config.
end_per_group(_Group, _Config) -> ok.
@@ -152,10 +192,10 @@ basic_app_default_dirs(Config) ->
[Name] = ?config(appnames, Config),
Result = ?config(result, Config),
- Expect = filename:absname(filename:join([AppDir, "_build", "test", "lib", Name, "test"])),
+ Expect = filename:join([AppDir, "_build", "test", "lib", Name, "test"]),
Dir = proplists:get_value(dir, Result),
- Expect = Dir.
+ [Expect] = Dir.
basic_app_default_beams(Config) ->
AppDir = ?config(apps, Config),
@@ -178,7 +218,7 @@ multi_app_default_dirs(Config) ->
Expect1 = filename:absname(filename:join([AppDir, "_build", "test", "lib", Name1, "test"])),
Expect2 = filename:absname(filename:join([AppDir, "_build", "test", "lib", Name2, "test"])),
- Expect3 = filename:absname(filename:join([AppDir, "_build", "test", "test"])),
+ Expect3 = filename:absname(filename:join([AppDir, "_build", "test", "extras", "test"])),
Dirs = proplists:get_value(dir, Result),
true = (lists:sort([Expect1, Expect2, Expect3]) == lists:sort(Dirs)).
@@ -215,8 +255,7 @@ multi_app_default_beams(Config) ->
single_app_dir(Config) ->
AppDir = ?config(apps, Config),
[Name1, _Name2] = ?config(appnames, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -233,17 +272,19 @@ single_app_dir(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = filename:absname(filename:join([AppDir, "_build", "test", "lib", Name1, "test"])),
- Dir = proplists:get_value(dir, Result),
+ Expect = filename:join([AppDir, "_build", "test", "lib", Name1, "test"]),
+ Dir = proplists:get_value(dir, Opts),
- Expect = Dir.
+ [Expect] = Dir.
single_extra_dir(Config) ->
AppDir = ?config(apps, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -257,22 +298,24 @@ single_extra_dir(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = filename:absname(filename:join([AppDir, "_build", "test", "test"])),
- Dir = proplists:get_value(dir, Result),
+ Expect = filename:join([AppDir, "_build", "test", "extras", "test"]),
+ Dir = proplists:get_value(dir, Opts),
- Expect = Dir.
+ [Expect] = Dir.
single_unmanaged_dir(Config) ->
PrivDir = ?config(priv_dir, Config),
+ State = ?config(s, Config),
Suite = filename:join([PrivDir, "unmanaged_dir", "unmanaged_dir_SUITE.erl"]),
ok = filelib:ensure_dir(Suite),
ok = file:write_file(Suite, test_suite("unmanaged_dir")),
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
-
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -285,18 +328,20 @@ single_unmanaged_dir(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = filename:absname(filename:join([PrivDir, "unmanaged_dir"])),
- Dir = proplists:get_value(dir, Result),
+ Expect = filename:join([PrivDir, "unmanaged_dir"]),
+ Dir = proplists:get_value(dir, Opts),
- Expect = Dir.
+ [Expect] = Dir.
single_suite(Config) ->
AppDir = ?config(apps, Config),
[Name1, _Name2] = ?config(appnames, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -314,24 +359,26 @@ single_suite(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = [filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "lib",
- Name1,
- "test",
- Name1 ++ "_SUITE"]))],
- Suite = proplists:get_value(suite, Result),
+ Expect = filename:join([AppDir,
+ "_build",
+ "test",
+ "lib",
+ Name1,
+ "test",
+ Name1 ++ "_SUITE"]),
+ Suite = proplists:get_value(suite, Opts),
- Expect = Suite.
+ [Expect] = Suite.
single_extra_suite(Config) ->
AppDir = ?config(apps, Config),
[_Name1, _Name2] = ?config(appnames, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -347,27 +394,30 @@ single_extra_suite(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = [filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "test",
- "extra_SUITE"]))],
- Suite = proplists:get_value(suite, Result),
+ Expect = filename:join([AppDir,
+ "_build",
+ "test",
+ "extras",
+ "test",
+ "extra_SUITE"]),
+ Suite = proplists:get_value(suite, Opts),
- Expect = Suite.
+ [Expect] = Suite.
single_unmanaged_suite(Config) ->
PrivDir = ?config(priv_dir, Config),
[_Name1, _Name2] = ?config(appnames, Config),
+ State = ?config(s, Config),
Suite = filename:join([PrivDir, "unmanaged", "unmanaged_SUITE.erl"]),
ok = filelib:ensure_dir(Suite),
ok = file:write_file(Suite, test_suite("unmanaged")),
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
-
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -382,20 +432,22 @@ single_unmanaged_suite(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = [filename:absname(filename:join([PrivDir,
- "unmanaged",
- "unmanaged_SUITE"]))],
- SuitePath = proplists:get_value(suite, Result),
+ Expect = filename:join([PrivDir,
+ "unmanaged",
+ "unmanaged_SUITE"]),
+ SuitePath = proplists:get_value(suite, Opts),
- Expect = SuitePath.
+ [Expect] = SuitePath.
multi_suite(Config) ->
AppDir = ?config(apps, Config),
[Name1, Name2] = ?config(appnames, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -417,31 +469,33 @@ multi_suite(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
-
- Expect1 = filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "lib",
- Name1,
- "test",
- Name1 ++ "_SUITE"])),
- Expect2 = filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "lib",
- Name2,
- "test",
- Name2 ++ "_SUITE"])),
- Suites = proplists:get_value(suite, Result),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
+
+ Expect1 = filename:join([AppDir,
+ "_build",
+ "test",
+ "lib",
+ Name1,
+ "test",
+ Name1 ++ "_SUITE"]),
+ Expect2 = filename:join([AppDir,
+ "_build",
+ "test",
+ "lib",
+ Name2,
+ "test",
+ Name2 ++ "_SUITE"]),
+ Suites = proplists:get_value(suite, Opts),
true = (lists:sort([Expect1, Expect2]) == lists:sort(Suites)).
all_suite(Config) ->
AppDir = ?config(apps, Config),
[Name1, Name2] = ?config(appnames, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -465,36 +519,39 @@ all_suite(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
-
- Expect1 = filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "lib",
- Name1,
- "test",
- Name1 ++ "_SUITE"])),
- Expect2 = filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "lib",
- Name2,
- "test",
- Name2 ++ "_SUITE"])),
- Expect3 = filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "test",
- "extra_SUITE"])),
- Suites = proplists:get_value(suite, Result),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
+
+ Expect1 = filename:join([AppDir,
+ "_build",
+ "test",
+ "lib",
+ Name1,
+ "test",
+ Name1 ++ "_SUITE"]),
+ Expect2 = filename:join([AppDir,
+ "_build",
+ "test",
+ "lib",
+ Name2,
+ "test",
+ Name2 ++ "_SUITE"]),
+ Expect3 = filename:join([AppDir,
+ "_build",
+ "test",
+ "extras",
+ "test",
+ "extra_SUITE"]),
+ Suites = proplists:get_value(suite, Opts),
true = (lists:sort([Expect1, Expect2, Expect3]) == lists:sort(Suites)).
single_dir_and_single_suite(Config) ->
AppDir = ?config(apps, Config),
[_Name1, _Name2] = ?config(appnames, Config),
-
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+ State = ?config(s, Config),
LibDirs = rebar_dir:lib_dirs(State),
State1 = rebar_app_discover:do(State, LibDirs),
@@ -509,52 +566,369 @@ single_dir_and_single_suite(Config) ->
State2 = rebar_state:command_parsed_args(State1, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ Tests = rebar_prv_common_test:prepare_tests(State2),
+ {ok, NewState} = rebar_prv_common_test:compile(State2, Tests),
+ {ok, T} = Tests,
+ Opts = rebar_prv_common_test:translate_paths(NewState, T),
- Expect = [filename:absname(filename:join([AppDir,
- "_build",
- "test",
- "test",
- "extra_SUITE"]))],
- Suite = proplists:get_value(suite, Result),
+ Expect = filename:join([AppDir,
+ "_build",
+ "test",
+ "extras",
+ "test"]),
+ Dir = proplists:get_value(dir, Opts),
+ [Expect] = Dir,
- Expect = Suite.
+ Suite = proplists:get_value(suite, Opts),
+ ["extra_SUITE"] = Suite.
-symlinked_dir_overwritten_fix(Config) ->
- AppDir = ?config(apps, Config),
- [Name1, _Name2] = ?config(appnames, Config),
+%% this test probably only fails when this suite is run via rebar3 with the --cover flag
+data_dir_correct(Config) ->
+ DataDir = ?config(data_dir, Config),
+ Parts = filename:split(DataDir),
+ ["rebar_ct_SUITE_data","test","rebar","lib","test","_build"|_] = lists:reverse(Parts).
- {ok, State} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return),
+cmd_label(Config) ->
+ State = ?config(result, Config),
- LibDirs = rebar_dir:lib_dirs(State),
- State1 = rebar_app_discover:do(State, LibDirs),
+ 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, ["--label=this_is_a_label"]),
- Providers = rebar_state:providers(State1),
- Namespace = rebar_state:namespace(State1),
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({label, "this_is_a_label"}, TestOpts).
+
+cmd_config(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,
- ["--dir=" ++ filename:join([AppDir,
- "apps",
- Name1])]),
+ {ok, GetOptResult} = getopt:parse(GetOptSpec, ["--config=config/foo,config/bar,config/baz"]),
- State2 = rebar_state:command_parsed_args(State1, GetOptResult),
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
- Result = rebar_prv_common_test:setup_ct(State2),
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
- Expect = filename:absname(filename:join([AppDir, "_build", "test", "lib", Name1])),
- Dir = proplists:get_value(dir, Result),
+ true = lists:member({config, ["config/foo", "config/bar", "config/baz"]}, TestOpts).
- Expect = Dir,
+cmd_allow_user_terms(Config) ->
+ State = ?config(result, Config),
- {ok, _} = rebar_test_utils:run_and_check(Config, [], ["as", "test", "compile"], return).
+ 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, ["--allow_user_terms=true"]),
-%% this test probably only fails when this suite is run via rebar3 with the --cover flag
-data_dir_correct(Config) ->
- DataDir = ?config(data_dir, Config),
- Parts = filename:split(DataDir),
- ["rebar_ct_SUITE_data","test","rebar","lib","test","_build"|_] = lists:reverse(Parts).
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({allow_user_terms, true}, TestOpts).
+
+cmd_logdir(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, ["--logdir=/tmp/ct_logs"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({logdir, "/tmp/ct_logs"}, TestOpts).
+
+cmd_logopts(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, ["--logopts=no_src,no_nl"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({logopts, [no_src, no_nl]}, TestOpts).
+
+cmd_verbosity(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, ["--verbosity=43"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({verbosity, 43}, TestOpts).
+
+cmd_repeat(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, ["--repeat=3"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({repeat, 3}, TestOpts).
+
+cmd_duration(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, ["--duration=001500"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({duration, "001500"}, TestOpts).
+
+cmd_until(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, ["--until=001500"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({until, "001500"}, TestOpts).
+
+cmd_force_stop(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, ["--force_stop=skip_rest"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({force_stop, skip_rest}, TestOpts).
+
+cmd_basic_html(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, ["--basic_html"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({basic_html, true}, TestOpts).
+
+cmd_stylesheet(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, ["--stylesheet=resources/tests.css"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({stylesheet, "resources/tests.css"}, TestOpts).
+
+cmd_decrypt_key(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, ["--decrypt_key==ac467e30"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({decrypt_key, "=ac467e30"}, TestOpts).
+
+cmd_decrypt_file(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, ["--decrypt_file=../keyfile.pem"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({decrypt_file, "../keyfile.pem"}, TestOpts).
+
+cmd_abort_if_missing_suites(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, ["--abort_if_missing_suites"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({abort_if_missing_suites, true}, TestOpts).
+
+cmd_multiply_timetraps(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, ["--multiply_timetraps=3"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({multiply_timetraps, 3}, TestOpts).
+
+cmd_scale_timetraps(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, ["--scale_timetraps"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({scale_timetraps, true}, TestOpts).
+
+cmd_create_priv_dir(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, ["--create_priv_dir=manual_per_tc"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(NewState),
+
+ true = lists:member({create_priv_dir, manual_per_tc}, TestOpts).
+
+cfg_opts(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_opts_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_opts_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_opts, [{label, "this_is_a_label"}, {decrypt_file, "../keyfile.pem"}]}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(State),
+
+ true = lists:member({label, "this_is_a_label"}, TestOpts),
+ true = lists:member({decrypt_file, "../keyfile.pem"}, TestOpts).
+
+%% allow even nonsensical opts to be passed to ct_run for futureproofing
+cfg_arbitrary_opts(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_arbitrary_opts_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_arbitrary_opts_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_opts, [{foo, 1}, {bar, 2}, {baz, 3}]}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(State),
+
+ true = lists:member({foo, 1}, TestOpts),
+ true = lists:member({bar, 2}, TestOpts),
+ true = lists:member({baz, 3}, TestOpts).
+
+cfg_test_spec_filtered(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_test_spec_filtered_opts_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_test_spec_filtered_opts_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_opts, [{test_spec, "spec/foo.spec"}]}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(State),
+
+ false = lists:keysearch(test_spec, 1, TestOpts).
+
+cfg_atom_suites(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_atom_suites_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_atom_suites_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_opts, [{suite, [foo, bar, baz]}]}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ {ok, TestOpts} = rebar_prv_common_test:prepare_tests(State),
+ true = lists:member({suite, ["foo", "bar", "baz"]}, TestOpts).
%% helper for generating test data
test_suite(Name) ->
diff --git a/test/rebar_dialyzer_SUITE.erl b/test/rebar_dialyzer_SUITE.erl
index 31e02d9..22a4894 100644
--- a/test/rebar_dialyzer_SUITE.erl
+++ b/test/rebar_dialyzer_SUITE.erl
@@ -69,7 +69,16 @@ update_base_plt(Config) ->
?assertEqual(ErtsFiles, BasePltFiles2),
{ok, PltFiles} = plt_files(Plt),
- ?assertEqual(ErtsFiles, PltFiles).
+ ?assertEqual(ErtsFiles, PltFiles),
+
+ add_missing_file(BasePlt),
+ ok = file:delete(Plt),
+
+ rebar_test_utils:run_and_check(Config, RebarConfig, ["dialyzer"],
+ {ok, [{app, Name}]}),
+
+ {ok, BasePltFiles3} = plt_files(BasePlt),
+ ?assertEqual(ErtsFiles, BasePltFiles3).
update_app_plt(Config) ->
@@ -103,7 +112,15 @@ update_app_plt(Config) ->
{ok, [{app, Name}]}),
{ok, PltFiles3} = plt_files(Plt),
- ?assertEqual(ErtsFiles, PltFiles3).
+ ?assertEqual(ErtsFiles, PltFiles3),
+
+ add_missing_file(Plt),
+
+ rebar_test_utils:run_and_check(Config, RebarConfig, ["dialyzer"],
+ {ok, [{app, Name}]}),
+
+ {ok, PltFiles4} = plt_files(Plt),
+ ?assertEqual(ErtsFiles, PltFiles4).
build_release_plt(Config) ->
AppDir = ?config(apps, Config),
@@ -211,6 +228,19 @@ alter_plt(Plt) ->
{files, [code:which(dialyzer)]}]),
ok.
+add_missing_file(Plt) ->
+ Source = code:which(dialyzer),
+ Dest = filename:join(filename:dirname(Plt), "dialyzer.beam"),
+ {ok, _} = file:copy(Source, Dest),
+ _ = try
+ dialyzer:run([{analysis_type, plt_add},
+ {init_plt, Plt},
+ {files, [Dest]}])
+ after
+ ok = file:delete(Dest)
+ end,
+ ok.
+
-spec merge_config(Config, Config) -> Config when
Config :: [{term(), term()}].
merge_config(NewConfig, OldConfig) ->