summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_compile_SUITE.erl42
-rw-r--r--test/rebar_dir_SUITE.erl66
2 files changed, 103 insertions, 5 deletions
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl
index f31ab39..3e4d5b9 100644
--- a/test/rebar_compile_SUITE.erl
+++ b/test/rebar_compile_SUITE.erl
@@ -46,7 +46,8 @@
include_file_in_src_test/1,
always_recompile_when_erl_compiler_options_set/1,
recompile_when_parse_transform_inline_changes/1,
- recompile_when_parse_transform_as_opt_changes/1]).
+ recompile_when_parse_transform_as_opt_changes/1,
+ recursive/1,no_recursive/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -72,7 +73,8 @@ all() ->
include_file_relative_to_working_directory, include_file_in_src,
include_file_relative_to_working_directory_test, include_file_in_src_test,
recompile_when_parse_transform_as_opt_changes,
- recompile_when_parse_transform_inline_changes] ++
+ recompile_when_parse_transform_inline_changes,
+ recursive, no_recursive] ++
case erlang:function_exported(os, unsetenv, 1) of
true -> [always_recompile_when_erl_compiler_options_set];
false -> []
@@ -1520,3 +1522,39 @@ recompile_when_parse_transform_as_opt_changes(Config) ->
?assert(ModTime =/= NewModTime).
+recursive(Config) ->
+ AppDir = ?config(apps, Config),
+
+ 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]),
+ rebar_test_utils:write_src_file(filename:join(AppDir,src),"rec.erl"),
+
+ rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
+
+ EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
+ {ok, Files} = rebar_utils:list_dir(EbinDir),
+ ?assert(lists:member("rec.beam",Files)).
+
+no_recursive(Config) ->
+ AppDir = ?config(apps, Config),
+
+ 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]),
+ rebar_test_utils:write_src_file(filename:join(AppDir,src),"rec.erl"),
+
+ RebarConfig1 = [{erlc_compiler,[{recursive,false}]}],
+ rebar_test_utils:run_and_check(Config, RebarConfig1, ["compile"],
+ {ok, [{app, Name}]}),
+ EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
+ {ok, Files1} = rebar_utils:list_dir(EbinDir),
+ ?assert(false==lists:member("rec.beam",Files1)),
+
+ RebarConfig2 = [{src_dirs,[{"src",[{recursive,false}]}]}],
+ rebar_test_utils:run_and_check(Config, RebarConfig2, ["compile"],
+ {ok, [{app, Name}]}),
+ {ok, Files2} = rebar_utils:list_dir(EbinDir),
+ ?assert(false==lists:member("rec.beam",Files2)),
+
+ ok.
diff --git a/test/rebar_dir_SUITE.erl b/test/rebar_dir_SUITE.erl
index 9734830..6797802 100644
--- a/test/rebar_dir_SUITE.erl
+++ b/test/rebar_dir_SUITE.erl
@@ -3,8 +3,10 @@
-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([src_dirs/1, src_dirs_with_opts/1, extra_src_dirs/1, all_src_dirs/1]).
+-export([src_dir_opts/1, recursive/1]).
-export([profile_src_dirs/1, profile_extra_src_dirs/1, profile_all_src_dirs/1]).
+-export([profile_src_dir_opts/1]).
-export([retarget_path/1, alt_base_dir_abs/1, alt_base_dir_rel/1]).
-export([global_cache_dir/1, default_global_cache_dir/1, overwrite_default_global_cache_dir/1]).
@@ -14,8 +16,9 @@
all() -> [default_src_dirs, default_extra_src_dirs, default_all_src_dirs,
- src_dirs, extra_src_dirs, all_src_dirs,
+ src_dirs, extra_src_dirs, all_src_dirs, src_dir_opts, recursive,
profile_src_dirs, profile_extra_src_dirs, profile_all_src_dirs,
+ profile_src_dir_opts,
retarget_path, alt_base_dir_abs, alt_base_dir_rel, global_cache_dir,
default_global_cache_dir, overwrite_default_global_cache_dir].
@@ -70,6 +73,13 @@ src_dirs(Config) ->
["bar", "baz", "foo"] = rebar_dir:src_dirs(rebar_state:opts(State)).
+src_dirs_with_opts(Config) ->
+ RebarConfig = [{erl_opts, [{src_dirs, ["foo", "bar", "baz"]},
+ {src_dirs, [{"foo",[{recursive,false}]}, "qux"]}]}],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
+
+ ["bar", "baz", "foo", "qux"] = rebar_dir:src_dirs(rebar_state:opts(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),
@@ -77,11 +87,41 @@ extra_src_dirs(Config) ->
["bar", "baz", "foo"] = rebar_dir:extra_src_dirs(rebar_state:opts(State)).
all_src_dirs(Config) ->
- RebarConfig = [{erl_opts, [{src_dirs, ["foo", "bar"]}, {extra_src_dirs, ["baz", "qux"]}]}],
+ RebarConfig = [{erl_opts, [{src_dirs, ["foo", "bar"]}, {extra_src_dirs, ["baz", "qux"]}, {src_dirs, [{"foo", [{recursive,false}]}]}]}],
{ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
["bar", "baz", "foo", "qux"] = rebar_dir:all_src_dirs(rebar_state:opts(State)).
+src_dir_opts(Config) ->
+ RebarConfig =
+ [{erl_opts, [{src_dirs, [{"foo",[{recursive,true}]}, "bar"]},
+ {extra_src_dirs, ["baz", {"foo", [{recursive,false}]}]},
+ {src_dirs, [{"foo", [{recursive,false}]}]}]}],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig,
+ ["compile"], return),
+ [{recursive,true}] = rebar_dir:src_dir_opts(rebar_state:opts(State), "foo"),
+ [] = rebar_dir:src_dir_opts(rebar_state:opts(State), "bar"),
+ [] = rebar_dir:src_dir_opts(rebar_state:opts(State), "nonexisting").
+
+recursive(Config) ->
+ RebarConfig1 =
+ [{erl_opts, [{src_dirs, ["foo", "bar"]},
+ {extra_src_dirs, ["baz", {"foo", [{recursive,true}]}]},
+ {src_dirs, [{"foo", [{recursive,false}]}]}]}],
+ {ok, State1} = rebar_test_utils:run_and_check(Config, RebarConfig1,
+ ["compile"], return),
+ false = rebar_dir:recursive(rebar_state:opts(State1), "foo"),
+ true = rebar_dir:recursive(rebar_state:opts(State1), "bar"),
+
+ RebarConfig2 = [{erlc_compiler,[{recursive,false}]},
+ {erl_opts,[{src_dirs,["foo",{"bar",[{recursive,true}]}]}]}],
+ {ok, State2} = rebar_test_utils:run_and_check(Config, RebarConfig2,
+ ["compile"], return),
+ false = rebar_dir:recursive(rebar_state:opts(State2), "foo"),
+ true = rebar_dir:recursive(rebar_state:opts(State2), "bar"),
+
+ ok.
+
profile_src_dirs(Config) ->
RebarConfig = [
{erl_opts, [{src_dirs, ["foo", "bar"]}]},
@@ -118,6 +158,26 @@ profile_all_src_dirs(Config) ->
R = lists:sort(["foo", "bar", "baz", "qux"]),
R = rebar_dir:all_src_dirs(rebar_state:opts(State)).
+profile_src_dir_opts(Config) ->
+ RebarConfig = [
+ {erl_opts, [{src_dirs, ["foo"]},
+ {extra_src_dirs, [{"bar",[recursive]}]}]},
+ {profiles, [
+ {more, [{erl_opts, [{src_dirs, [{"bar",[{recursive,false}]}]},
+ {extra_src_dirs, ["qux"]}]}]}
+ ]}
+ ],
+ {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig,
+ ["as", "more", "compile"],
+ return),
+
+ [{recursive,false}] = rebar_dir:src_dir_opts(rebar_state:opts(State),"bar"),
+
+ {ok, State1} = rebar_test_utils:run_and_check(Config, RebarConfig,
+ ["compile"], return),
+
+ [{recursive,true}] = rebar_dir:src_dir_opts(rebar_state:opts(State1),"bar").
+
retarget_path(Config) ->
{ok, State} = rebar_test_utils:run_and_check(Config, [], ["compile"], return),