summaryrefslogtreecommitdiff
path: root/systest
diff options
context:
space:
mode:
authorStuart Thackray <stuart.thackray@gmail.com>2018-12-11 08:53:29 +0200
committerStuart Thackray <stuart.thackray@gmail.com>2018-12-11 08:53:29 +0200
commitebfa797c1f5d038b99beaf658757d974412a15c7 (patch)
tree9765880a7f0119c265d85f8bac7afea8d9542080 /systest
parent71187514dabdd94aa333495d92df84a2e750099f (diff)
parent8e28561d4e14ea85d42d17ab5a0f17f5f1c696d2 (diff)
Update from Upstream
Diffstat (limited to 'systest')
-rw-r--r--systest/all_SUITE.erl117
-rw-r--r--systest/all_SUITE_data/alias_clash/rebar.config4
-rw-r--r--systest/all_SUITE_data/alias_clash/src/alias_clash.app.src15
-rw-r--r--systest/all_SUITE_data/alias_clash/src/alias_clash.erl13
-rw-r--r--systest/all_SUITE_data/compile_deps/rebar.config8
-rw-r--r--systest/all_SUITE_data/compile_deps/rebar.config.script2
-rw-r--r--systest/all_SUITE_data/compile_deps/vendored/fake_dep/rebar.config2
-rw-r--r--systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.app.src15
-rw-r--r--systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.erl13
-rw-r--r--systest/all_SUITE_data/grisp_explode/rebar.config16
-rw-r--r--systest/all_SUITE_data/grisp_explode/rebar.lock8
-rw-r--r--systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src17
-rw-r--r--systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl15
-rw-r--r--systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl19
-rw-r--r--systest/all_SUITE_data/resource_plugins/rebar.config23
15 files changed, 287 insertions, 0 deletions
diff --git a/systest/all_SUITE.erl b/systest/all_SUITE.erl
new file mode 100644
index 0000000..083fae9
--- /dev/null
+++ b/systest/all_SUITE.erl
@@ -0,0 +1,117 @@
+-module(all_SUITE).
+-include_lib("common_test/include/ct.hrl").
+-include_lib("eunit/include/eunit.hrl").
+-compile([export_all, nowarn_export_all]).
+
+init_per_suite(Config) ->
+ %% TODO: figure out how to use a local rebar3 copy?
+ %% Ensure global rebar3 has the same version as current one!
+ {ok, Vsn} = application:get_key(rebar, vsn),
+ {ok, ExecVsn} = rebar3("version", [{path, "."} | Config]),
+ case rebar_string:lexemes(ExecVsn, " ") of
+ ["rebar", Vsn | _] ->
+ %% Copy all base cases to priv_dir
+ rebar_file_utils:cp_r([?config(data_dir, Config)],
+ ?config(priv_dir, Config)),
+ Config;
+ _ ->
+ {skip, "expected current version "++Vsn++" in path "
+ "and found '"++ ExecVsn ++ "'"}
+ end.
+
+end_per_suite(Config) ->
+ Config.
+
+init_per_testcase(Name, Config) ->
+ set_name_config(Name, Config).
+
+end_per_testcase(_Name, Config) ->
+ Config.
+
+all() ->
+ [noop, resource_plugins, alias_clash, grisp_explode, compile_deps].
+
+%groups() ->
+% [{plugins, [shuffle], []},
+% {deps, [shuffle], []}].
+
+%%%%%%%%%%%%%%%%%%
+%%% TEST CASES %%%
+%%%%%%%%%%%%%%%%%%
+
+noop() ->
+ [{doc, "just a sanity check on the handling of the test suite init/end"}].
+noop(_Config) ->
+ true.
+
+resource_plugins() ->
+ [{doc, "Issue #1673: "
+ "Ensure that deps using resource plugins with semver compile."}].
+resource_plugins(Config) ->
+ %% When the environment handling is wrong, the run fails violently.
+ {ok, Output} = rebar3("compile", 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.
+
+grisp_explode() ->
+ [{doc, "Don't force purge a plugin that runs the compile job itself"}].
+grisp_explode(Config) ->
+ %% When the purge handling is wrong, the run fails violently.
+ {error, {_,Output}} = rebar3("grisp deploy -n robot -v 0.1.0", Config),
+ ct:pal("Rebar3 Output:~n~s",[Output]),
+ ?assertNotEqual(nomatch,
+ re:run(Output, "No releases exist in the system for robot:0.1.0!")
+ ),
+ ok.
+
+compile_deps() ->
+ [{doc, "When compiling a project multiple times, the deps should always be built event if refetched"}].
+compile_deps(Config) ->
+ rebar3("compile", Config),
+ rebar3("compile", Config),
+
+ PrivDir = ?config(path, Config),
+ EbinDir = filename:join([PrivDir, "_build", "default", "lib", "fake_dep", "ebin"]),
+
+ {ok, Beams} = file:list_dir(EbinDir),
+ ?assert(length(Beams) > 1).
+
+
+%%%%%%%%%%%%%%%
+%%% Helpers %%%
+%%%%%%%%%%%%%%%
+set_name_config(Atom, Config) ->
+ [{path,
+ filename:join([?config(priv_dir, Config),
+ atom_to_list(?MODULE)++"_data", atom_to_list(Atom)])}
+ | Config].
+
+rebar3(Args, Config) -> rebar3(Args, Config, []).
+
+rebar3(Args, Config, UserOpts) ->
+ Exec = case os:type() of
+ {win32, _} ->
+ "rebar3.cmd";
+ _ ->
+ "rebar3"
+ end,
+ Cmd = Exec ++ " " ++ Args,
+ 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
+%%====================================================================
diff --git a/systest/all_SUITE_data/compile_deps/rebar.config b/systest/all_SUITE_data/compile_deps/rebar.config
new file mode 100644
index 0000000..08e2f62
--- /dev/null
+++ b/systest/all_SUITE_data/compile_deps/rebar.config
@@ -0,0 +1,8 @@
+{deps, [
+ {fake_dep, {localdep, "fake_dep"}}
+ ]}.
+
+{plugins, [{rebar_localdep,
+ {git, "https://github.com/alinpopa/rebar3-localdep-plugin.git",
+ {branch, "master"}}}]}.
+
diff --git a/systest/all_SUITE_data/compile_deps/rebar.config.script b/systest/all_SUITE_data/compile_deps/rebar.config.script
new file mode 100644
index 0000000..c0ebab1
--- /dev/null
+++ b/systest/all_SUITE_data/compile_deps/rebar.config.script
@@ -0,0 +1,2 @@
+os:putenv("LOCALDEP_DIR", "./vendored/").
+CONFIG.
diff --git a/systest/all_SUITE_data/compile_deps/vendored/fake_dep/rebar.config b/systest/all_SUITE_data/compile_deps/vendored/fake_dep/rebar.config
new file mode 100644
index 0000000..f618f3e
--- /dev/null
+++ b/systest/all_SUITE_data/compile_deps/vendored/fake_dep/rebar.config
@@ -0,0 +1,2 @@
+{erl_opts, [debug_info]}.
+{deps, []}. \ No newline at end of file
diff --git a/systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.app.src b/systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.app.src
new file mode 100644
index 0000000..8547c35
--- /dev/null
+++ b/systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.app.src
@@ -0,0 +1,15 @@
+{application, fake_dep,
+ [{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/compile_deps/vendored/fake_dep/src/fake_dep.erl b/systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.erl
new file mode 100644
index 0000000..db8d9f0
--- /dev/null
+++ b/systest/all_SUITE_data/compile_deps/vendored/fake_dep/src/fake_dep.erl
@@ -0,0 +1,13 @@
+-module(fake_dep).
+
+%% API exports
+-export([]).
+
+%%====================================================================
+%% API functions
+%%====================================================================
+
+
+%%====================================================================
+%% Internal functions
+%%====================================================================
diff --git a/systest/all_SUITE_data/grisp_explode/rebar.config b/systest/all_SUITE_data/grisp_explode/rebar.config
new file mode 100644
index 0000000..43c9f63
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/rebar.config
@@ -0,0 +1,16 @@
+{deps, [grisp]}.
+
+{plugins, [{rebar3_grisp, "0.1.0"}]}.
+
+{erl_opts, [debug_info]}.
+
+{grisp, [
+ {otp_release, "19"},
+ {deploy, [
+ {destination, "/path/to/SD-card"}
+ ]}
+]}.
+
+{relx, [
+ {release, {mygrispproject, "0.1.0"}, [mygrispproject]}
+]}.
diff --git a/systest/all_SUITE_data/grisp_explode/rebar.lock b/systest/all_SUITE_data/grisp_explode/rebar.lock
new file mode 100644
index 0000000..2523b13
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/rebar.lock
@@ -0,0 +1,8 @@
+{"1.1.0",
+[{<<"grisp">>,{pkg,<<"grisp">>,<<"0.1.1">>},0},
+ {<<"mapz">>,{pkg,<<"mapz">>,<<"0.3.0">>},1}]}.
+[
+{pkg_hash,[
+ {<<"grisp">>, <<"5A1318E7B1582D7C5B1E446D149A6F93428A380BCFE7D740E57E4F6B6CDB19DD">>},
+ {<<"mapz">>, <<"438D24746CE5A252101E00B2032EFDF7FC69EB32689D3B805DE5E6DD7F52614F">>}]}
+].
diff --git a/systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src
new file mode 100644
index 0000000..0f0a396
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src
@@ -0,0 +1,17 @@
+{application, mygrispproject, [
+ {description, "A GRiSP application"},
+ {vsn, "0.1.0"},
+ {registered, []},
+ {mod, {mygrispproject, []}},
+ {applications, [
+ kernel,
+ stdlib,
+ grisp
+ ]},
+ {env,[]},
+ {modules, []},
+
+ {maintainers, []},
+ {licenses, ["Apache 2.0"]},
+ {links, []}
+]}.
diff --git a/systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl
new file mode 100644
index 0000000..a9152fe
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl
@@ -0,0 +1,15 @@
+% @doc mygrispproject public API.
+% @end
+-module(mygrispproject).
+
+-behavior(application).
+
+% Callbacks
+-export([start/2]).
+-export([stop/1]).
+
+%--- Callbacks -----------------------------------------------------------------
+
+start(_Type, _Args) -> mygrispproject_sup:start_link().
+
+stop(_State) -> ok.
diff --git a/systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl b/systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl
new file mode 100644
index 0000000..aef0d4f
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl
@@ -0,0 +1,19 @@
+% @doc mygrispproject top level supervisor.
+% @end
+-module(mygrispproject_sup).
+
+-behavior(supervisor).
+
+% API
+-export([start_link/0]).
+
+% Callbacks
+-export([init/1]).
+
+%--- API -----------------------------------------------------------------------
+
+start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%--- Callbacks -----------------------------------------------------------------
+
+init([]) -> {ok, { {one_for_all, 0, 1}, []} }.
diff --git a/systest/all_SUITE_data/resource_plugins/rebar.config b/systest/all_SUITE_data/resource_plugins/rebar.config
new file mode 100644
index 0000000..7df4a4a
--- /dev/null
+++ b/systest/all_SUITE_data/resource_plugins/rebar.config
@@ -0,0 +1,23 @@
+%% Sample provided by @tothlac
+{plugins, [
+ {rebar_tidy_deps, ".*", {git, "https://github.com/tothlac/rebar3-tidy-deps-plugin.git"}},
+ {rebar_alias, {git, "https://github.com/tsloughter/rebar_alias.git"}},
+ rebar3_appup_plugin
+]}.
+
+{deps, [
+ {hackney, {git, "https://github.com/benoitc/hackney.git", {tag, "1.10.1"}}}
+ ]}.
+
+
+%% Make work despite compat issues with strings and warnings
+{overrides, [
+ {override, rebar3_appup_plugin, [
+ {erl_opts, [
+ {platform_define, "^19", brutal_purge_fixed},
+ {platform_define, "^2", brutal_purge_fixed},
+ %% warnings_as_errors,
+ debug_info
+ ]}
+ ]}
+]}.