summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralisdair sullivan <alisdair.sullivan@askuity.com>2015-05-19 11:41:18 -0700
committeralisdair sullivan <alisdair.sullivan@askuity.com>2015-05-19 11:48:53 -0700
commitd05103a4a878c7c65d9fa90df6a6c223d0542d94 (patch)
tree0673bca4a949cfc2fbb939f1b236e8eee05e9e1c /test
parentf9c9e0eacca3e9e42cf7dccbb178dd6c7b8f5c68 (diff)
methods for retrieving `src_dirs` and `extra_src_dirs`
note that now ALL `src_dirs` across included profiles are compiled. previously only the last included profile's `src_dirs` were used
Diffstat (limited to 'test')
-rw-r--r--test/rebar_dir_SUITE.erl99
1 files changed, 99 insertions, 0 deletions
diff --git a/test/rebar_dir_SUITE.erl b/test/rebar_dir_SUITE.erl
new file mode 100644
index 0000000..a3c5052
--- /dev/null
+++ b/test/rebar_dir_SUITE.erl
@@ -0,0 +1,99 @@
+-module(rebar_dir_SUITE).
+
+-export([all/0, init_per_testcase/2, end_per_testcase/2]).
+
+-export([default_src_dirs/1, default_extra_src_dirs/1, default_all_src_dirs/1]).
+-export([src_dirs/1, extra_src_dirs/1, all_src_dirs/1]).
+-export([profile_src_dirs/1, profile_extra_src_dirs/1, profile_all_src_dirs/1]).
+
+-include_lib("common_test/include/ct.hrl").
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("kernel/include/file.hrl").
+
+
+all() -> [default_src_dirs, default_extra_src_dirs, default_all_src_dirs,
+ src_dirs, extra_src_dirs, all_src_dirs,
+ profile_src_dirs, profile_extra_src_dirs, profile_all_src_dirs].
+
+init_per_testcase(_, Config) ->
+ C = rebar_test_utils:init_rebar_state(Config),
+ AppDir = ?config(apps, C),
+
+ 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]),
+ C.
+
+end_per_testcase(_, _Config) -> ok.
+
+default_src_dirs(Config) ->
+ {ok, State} = rebar_test_utils:run_and_check(Config, [], ["compile"], return),
+
+ [] = rebar_dir:src_dirs(State),
+ ["src"] = rebar_dir:src_dirs(State, ["src"]).
+
+default_extra_src_dirs(Config) ->
+ {ok, State} = rebar_test_utils:run_and_check(Config, [], ["compile"], return),
+
+ [] = rebar_dir:extra_src_dirs(State),
+ ["src"] = rebar_dir:extra_src_dirs(State, ["src"]).
+
+default_all_src_dirs(Config) ->
+ {ok, State} = rebar_test_utils:run_and_check(Config, [], ["compile"], return),
+
+ [] = rebar_dir:all_src_dirs(State),
+ ["src", "test"] = rebar_dir:all_src_dirs(State, ["src"], ["test"]).
+
+src_dirs(Config) ->
+ RebarConfig = [{erl_opts, [{src_dirs, ["foo", "bar", "baz"]}]}],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
+
+ ["foo", "bar", "baz"] = rebar_dir:src_dirs(State).
+
+extra_src_dirs(Config) ->
+ RebarConfig = [{erl_opts, [{extra_src_dirs, ["foo", "bar", "baz"]}]}],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
+
+ ["foo", "bar", "baz"] = rebar_dir:extra_src_dirs(State).
+
+all_src_dirs(Config) ->
+ RebarConfig = [{erl_opts, [{src_dirs, ["foo", "bar"]}, {extra_src_dirs, ["baz", "qux"]}]}],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
+
+ ["foo", "bar", "baz", "qux"] = rebar_dir:all_src_dirs(State).
+
+profile_src_dirs(Config) ->
+ RebarConfig = [
+ {erl_opts, [{src_dirs, ["foo", "bar"]}]},
+ {profiles, [
+ {more, [{erl_opts, [{src_dirs, ["baz", "qux"]}]}]}
+ ]}
+ ],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["as", "more", "compile"], return),
+
+ R = lists:sort(["foo", "bar", "baz", "qux"]),
+ R = lists:sort(rebar_dir:src_dirs(State)).
+
+profile_extra_src_dirs(Config) ->
+ RebarConfig = [
+ {erl_opts, [{extra_src_dirs, ["foo", "bar"]}]},
+ {profiles, [
+ {more, [{erl_opts, [{extra_src_dirs, ["baz", "qux"]}]}]}
+ ]}
+ ],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["as", "more", "compile"], return),
+
+ R = lists:sort(["foo", "bar", "baz", "qux"]),
+ R = lists:sort(rebar_dir:extra_src_dirs(State)).
+
+profile_all_src_dirs(Config) ->
+ RebarConfig = [
+ {erl_opts, [{src_dirs, ["foo"]}, {extra_src_dirs, ["bar"]}]},
+ {profiles, [
+ {more, [{erl_opts, [{src_dirs, ["baz"]}, {extra_src_dirs, ["qux"]}]}]}
+ ]}
+ ],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["as", "more", "compile"], return),
+
+ R = lists:sort(["foo", "bar", "baz", "qux"]),
+ R = lists:sort(rebar_dir:all_src_dirs(State)).