summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-01-27 20:52:35 -0800
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-02-08 15:30:36 -0800
commitc79d13f5e854ff84b4fe61a45ce666ee1c8479da (patch)
tree2a458b01a9b336ee3939694d68f044dd6358ed6d /test
parentd2cfe6a073d4d5d3092143c3925dacaab76ed472 (diff)
factor out task/args parsing from `do` for use in other meta
commands
Diffstat (limited to 'test')
-rw-r--r--test/rebar_utils_SUITE.erl120
1 files changed, 120 insertions, 0 deletions
diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl
new file mode 100644
index 0000000..e9b32e2
--- /dev/null
+++ b/test/rebar_utils_SUITE.erl
@@ -0,0 +1,120 @@
+-module(rebar_utils_SUITE).
+
+-export([all/0,
+ groups/0,
+ init_per_group/2,
+ end_per_group/2,
+ empty_arglist/1,
+ single_task/1,
+ single_task_with_immediate_comma/1,
+ single_task_with_trailing_comma/1,
+ multiple_task/1,
+ multiple_task_no_spaces/1,
+ multiple_task_with_immediate_comma/1,
+ multiple_task_with_trailing_comma/1,
+ task_with_arg/1,
+ task_with_arg_with_immediate_comma/1,
+ task_with_arg_with_trailing_comma/1,
+ task_with_multiple_args/1,
+ task_with_flag/1,
+ task_with_flag_with_immediate_comma/1,
+ task_with_flag_with_trailing_comma/1,
+ task_with_flag_with_commas/1,
+ task_with_multiple_flags/1,
+ special_task_do/1]).
+
+-include_lib("common_test/include/ct.hrl").
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("kernel/include/file.hrl").
+
+
+all() ->
+ [{group, args_to_tasks}].
+
+groups() ->
+ [{args_to_tasks, [], [empty_arglist,
+ single_task,
+ single_task_with_immediate_comma,
+ single_task_with_trailing_comma,
+ multiple_task,
+ multiple_task_no_spaces,
+ multiple_task_with_immediate_comma,
+ multiple_task_with_trailing_comma,
+ task_with_arg,
+ task_with_arg_with_immediate_comma,
+ task_with_arg_with_trailing_comma,
+ task_with_multiple_args,
+ task_with_flag,
+ task_with_flag_with_immediate_comma,
+ task_with_flag_with_trailing_comma,
+ task_with_flag_with_commas,
+ task_with_multiple_flags,
+ special_task_do]}].
+
+init_per_group(_, Config) -> Config.
+end_per_group(_, Config) -> Config.
+
+empty_arglist(_Config) ->
+ [] = rebar_utils:args_to_tasks([]).
+
+single_task(_Config) ->
+ [{"foo", []}] = rebar_utils:args_to_tasks(["foo"]).
+
+single_task_with_immediate_comma(_Config) ->
+ [{"foo", []}] = rebar_utils:args_to_tasks(["foo,"]).
+
+single_task_with_trailing_comma(_Config) ->
+ [{"foo", []}] = rebar_utils:args_to_tasks(["foo", ","]).
+
+multiple_task(_Config) ->
+ [{"foo", []}, {"bar", []}, {"baz", []}] = rebar_utils:args_to_tasks(["foo,",
+ "bar,",
+ "baz"]).
+
+multiple_task_no_spaces(_Config) ->
+ [{"foo", []}, {"bar", []}, {"baz", []}] = rebar_utils:args_to_tasks(["foo,bar,baz"]).
+
+multiple_task_with_immediate_comma(_Config) ->
+ [{"foo", []}, {"bar", []}, {"baz", []}] = rebar_utils:args_to_tasks(["foo,",
+ "bar,",
+ "baz,"]).
+
+multiple_task_with_trailing_comma(_Config) ->
+ [{"foo", []}, {"bar", []}, {"baz", []}] = rebar_utils:args_to_tasks(["foo",
+ ",",
+ "bar",
+ ",",
+ "baz",
+ ","]).
+task_with_arg(_Config) ->
+ [{"foo", ["bar"]}] = rebar_utils:args_to_tasks(["foo", "bar"]).
+
+task_with_arg_with_immediate_comma(_Config) ->
+ [{"foo", ["bar"]}, {"baz", []}] = rebar_utils:args_to_tasks(["foo", "bar,", "baz"]).
+
+task_with_arg_with_trailing_comma(_Config) ->
+ [{"foo", ["bar"]}, {"baz", []}] = rebar_utils:args_to_tasks(["foo", "bar", ",", "baz"]).
+
+task_with_multiple_args(_Config) ->
+ [{"foo", ["bar", "baz"]}] = rebar_utils:args_to_tasks(["foo", "bar", "baz"]).
+
+task_with_flag(_Config) ->
+ [{"foo", ["--bar"]}] = rebar_utils:args_to_tasks(["foo", "--bar"]).
+
+task_with_flag_with_immediate_comma(_Config) ->
+ [{"foo", ["--bar"]}, {"baz", []}] = rebar_utils:args_to_tasks(["foo", "--bar,", "baz"]).
+
+task_with_flag_with_trailing_comma(_Config) ->
+ [{"foo", ["--bar"]}, {"baz", []}] = rebar_utils:args_to_tasks(["foo", "--bar", ",", "baz"]).
+
+task_with_flag_with_commas(_Config) ->
+ [{"foo", ["--bar=baz,qux"]}] = rebar_utils:args_to_tasks(["foo", "--bar=baz,qux"]).
+
+task_with_multiple_flags(_Config) ->
+ [{"foo", ["--bar", "--baz"]}] = rebar_utils:args_to_tasks(["foo", "--bar", "--baz"]).
+
+special_task_do(_Config) ->
+ [{"foo", []}, {"do", ["bar,", "baz"]}] = rebar_utils:args_to_tasks(["foo,",
+ "do",
+ "bar,",
+ "baz"]).