diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2017-12-05 07:47:07 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2017-12-05 07:57:40 -0500 |
commit | 553a579b36fe0fb4a8bf464cd282d43c07d4e192 (patch) | |
tree | 92a62624f4be249cd583ea1f3c33145641087e09 /systest | |
parent | 46ea7e1e8f700d92947a0a9d8bfb0fb43b122a66 (diff) |
Alias plugin promoted to built-in command
- Uses the code at https://github.com/tsloughter/rebar_alias and brings
it within rebar3
- adds safety checks to prevent redefining built-in commands or obvious
circular dependencies between commands (indirect circular deps are
still possible)
- adds tests
- adds a systest to ensure no clash with the existing plugin
Diffstat (limited to 'systest')
-rw-r--r-- | systest/all_SUITE.erl | 24 | ||||
-rw-r--r-- | systest/all_SUITE_data/alias_clash/rebar.config | 4 | ||||
-rw-r--r-- | systest/all_SUITE_data/alias_clash/src/alias_clash.app.src | 15 | ||||
-rw-r--r-- | systest/all_SUITE_data/alias_clash/src/alias_clash.erl | 13 |
4 files changed, 53 insertions, 3 deletions
diff --git a/systest/all_SUITE.erl b/systest/all_SUITE.erl index 523e739..a0cfd3f 100644 --- a/systest/all_SUITE.erl +++ b/systest/all_SUITE.erl @@ -29,7 +29,7 @@ end_per_testcase(_Name, Config) -> Config. all() -> - [noop, resource_plugins]. + [noop, resource_plugins, alias_clash]. %groups() -> % [{plugins, [shuffle], []}, @@ -53,6 +53,21 @@ resource_plugins(Config) -> ct:pal("Rebar3 Output:~n~s",[Output]), ok. +alias_clash() -> + [{doc, "checking that the provider won't get plugin interference."}, + {timetrap, 10000}]. +alias_clash(Config) -> + {ok, Help} = rebar3("help", Config), % should be redefined, but by the plugin + ?assertNotEqual(nomatch, + re:run(Help, "Alias help is already the name of a command[a-z ]+and will be ignored") + ), + {ok, Output} = rebar3("test", Config, [{env, [{"DEBUG", "1"}]}]), + ?assertNotEqual(nomatch, re:run(Output, "cover summary written to:")), + ?assertNotEqual(nomatch, + re:run(Output, "Not adding provider default test from module rebar_prv_alias_test " + "because it already exists from module rebar_prv_alias_test")), + ok. + %%%%%%%%%%%%%%% %%% Helpers %%% %%%%%%%%%%%%%%% @@ -62,7 +77,9 @@ set_name_config(Atom, Config) -> atom_to_list(?MODULE)++"_data", atom_to_list(Atom)])} | Config]. -rebar3(Args, Config) -> +rebar3(Args, Config) -> rebar3(Args, Config, []). + +rebar3(Args, Config, UserOpts) -> Exec = case os:type() of {win32, _} -> "rebar3.cmd"; @@ -70,6 +87,7 @@ rebar3(Args, Config) -> "rebar3" end, Cmd = Exec ++ " " ++ Args, - Opts = [{cd, ?config(path, Config)}, return_on_error, use_stdout], + Opts = [{cd, ?config(path, Config)}, return_on_error, use_stdout + | UserOpts], ct:pal("Calling rebar3 ~s with options ~p", [Cmd, Opts]), rebar_utils:sh(Cmd, Opts). diff --git a/systest/all_SUITE_data/alias_clash/rebar.config b/systest/all_SUITE_data/alias_clash/rebar.config new file mode 100644 index 0000000..baf20a9 --- /dev/null +++ b/systest/all_SUITE_data/alias_clash/rebar.config @@ -0,0 +1,4 @@ +{alias, [{help, [version]}, % should be skipped, but be overriden by plugin + {test, [compile, {eunit, "-c"}, cover]}]}. + +{plugins, [rebar_alias]}. % should be overridden diff --git a/systest/all_SUITE_data/alias_clash/src/alias_clash.app.src b/systest/all_SUITE_data/alias_clash/src/alias_clash.app.src new file mode 100644 index 0000000..b4cdda2 --- /dev/null +++ b/systest/all_SUITE_data/alias_clash/src/alias_clash.app.src @@ -0,0 +1,15 @@ +{application, alias_clash, + [{description, "An OTP library"}, + {vsn, "0.1.0"}, + {registered, []}, + {applications, + [kernel, + stdlib + ]}, + {env,[]}, + {modules, []}, + + {maintainers, []}, + {licenses, ["Apache 2.0"]}, + {links, []} + ]}. diff --git a/systest/all_SUITE_data/alias_clash/src/alias_clash.erl b/systest/all_SUITE_data/alias_clash/src/alias_clash.erl new file mode 100644 index 0000000..9249cdb --- /dev/null +++ b/systest/all_SUITE_data/alias_clash/src/alias_clash.erl @@ -0,0 +1,13 @@ +-module(alias_clash). + +%% API exports +-export([]). + +%%==================================================================== +%% API functions +%%==================================================================== + + +%%==================================================================== +%% Internal functions +%%==================================================================== |