summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rebar.config.sample3
-rw-r--r--src/rebar_prv_common_test.erl2
-rw-r--r--src/rebar_prv_escriptize.erl8
-rw-r--r--src/rebar_templater.erl2
-rw-r--r--test/rebar_escriptize_SUITE.erl26
5 files changed, 35 insertions, 6 deletions
diff --git a/rebar.config.sample b/rebar.config.sample
index f57f8dc..54f32b2 100644
--- a/rebar.config.sample
+++ b/rebar.config.sample
@@ -128,7 +128,8 @@
%% Paths to miscellaneous Erlang files to compile for an app
%% without including them in its modules list
{extra_src_dirs, []}.
-
+%% Path where custom rebar3 templates could be found
+{template_dir, []}.
%% == EDoc ==
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index fbd0e89..1e0632e 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -221,7 +221,7 @@ select_tests(State, ProjectApps, CmdOpts, CfgOpts) ->
Configs = lists:flatmap(fun(Filename) ->
rebar_file_utils:consult_config(State, Filename)
end, SysConfigs),
- [application:load(Application) || Config <- SysConfigs, {Application, _} <- Config],
+ [application:load(Application) || Config <- Configs, {Application, _} <- Config],
rebar_utils:reread_config(Configs),
Merged = lists:ukeymerge(1,
diff --git a/src/rebar_prv_escriptize.erl b/src/rebar_prv_escriptize.erl
index e92c80d..06b54ed 100644
--- a/src/rebar_prv_escriptize.erl
+++ b/src/rebar_prv_escriptize.erl
@@ -72,8 +72,12 @@ do(State) ->
end;
Name ->
AllApps = rebar_state:all_deps(State)++rebar_state:project_apps(State),
- {ok, AppInfo} = rebar_app_utils:find(ec_cnv:to_binary(Name), AllApps),
- escriptize(State, AppInfo)
+ case rebar_app_utils:find(ec_cnv:to_binary(Name), AllApps) of
+ {ok, AppInfo} ->
+ escriptize(State, AppInfo);
+ _ ->
+ ?PRV_ERROR({bad_name, Name})
+ end
end.
escriptize(State0, App) ->
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 2f33bfc..299b957 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -326,7 +326,7 @@ find_other_templates(State) ->
undefined ->
[];
TemplateDir ->
- rebar_utils:find_files(TemplateDir, ?TEMPLATE_RE)
+ rebar_utils:find_files(TemplateDir, ?TEMPLATE_RE, true) % recursive
end.
%% Fetch template indexes that sit on disk in plugins
diff --git a/test/rebar_escriptize_SUITE.erl b/test/rebar_escriptize_SUITE.erl
index 1817d6b..139d5cd 100644
--- a/test/rebar_escriptize_SUITE.erl
+++ b/test/rebar_escriptize_SUITE.erl
@@ -5,6 +5,8 @@
end_per_suite/1,
init_per_testcase/2,
all/0,
+ escriptize_with_name/1,
+ escriptize_with_bad_name/1,
build_and_clean_app/1]).
-include_lib("common_test/include/ct.hrl").
@@ -24,7 +26,11 @@ init_per_testcase(_, Config) ->
rebar_test_utils:init_rebar_state(Config).
all() ->
- [build_and_clean_app].
+ [
+ build_and_clean_app,
+ escriptize_with_name,
+ escriptize_with_bad_name
+ ].
%% Test escriptize builds and runs the app's escript
build_and_clean_app(Config) ->
@@ -35,3 +41,21 @@ build_and_clean_app(Config) ->
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
rebar_test_utils:run_and_check(Config, [], ["escriptize"],
{ok, [{app, Name, valid}]}).
+
+escriptize_with_name(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:run_and_check(Config, [{escript_main_app, Name}], ["escriptize"],
+ {ok, [{app, Name, valid}]}).
+
+escriptize_with_bad_name(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:run_and_check(Config, [{escript_main_app, boogers}], ["escriptize"],
+ {error,{rebar_prv_escriptize, {bad_name, boogers}}}).