summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS1
-rwxr-xr-xbootstrap13
-rw-r--r--inttest/ct1/app.config2
-rw-r--r--inttest/ct1/ct1_rt.erl2
-rw-r--r--inttest/ct1/rebar.config1
-rw-r--r--inttest/ct1/test_SUITE.erl8
-rw-r--r--src/rebar_ct.erl22
-rw-r--r--src/rebar_shell.erl30
8 files changed, 64 insertions, 15 deletions
diff --git a/THANKS b/THANKS
index ef359ac..3db3b4c 100644
--- a/THANKS
+++ b/THANKS
@@ -126,3 +126,4 @@ Yuki Ito
alisdair sullivan
Alexander Verbitsky
Andras Horvath
+Drew Varner
diff --git a/bootstrap b/bootstrap
index 7086098..df09f7e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -3,6 +3,14 @@
%% ex: ft=erlang ts=4 sw=4 et
main(Args) ->
+ case lists:member("--help", Args) of
+ true ->
+ usage(),
+ halt(0);
+ false ->
+ ok
+ end,
+
%% Get a string repr of build time
Built = build_time(),
@@ -90,6 +98,11 @@ main(Args) ->
"Place this script anywhere in your path\n"
"and you can use rebar to build OTP-compliant apps.\n").
+usage() ->
+ io:format("Usage: bootstrap [OPTION]...~n"),
+ io:format(" force=1 unconditional build~n"),
+ io:format(" debug add debug information~n").
+
is_otp(OtpInfo, Regex) ->
case re:run(OtpInfo, Regex, [{capture, none}]) of
match -> true;
diff --git a/inttest/ct1/app.config b/inttest/ct1/app.config
new file mode 100644
index 0000000..bb718b2
--- /dev/null
+++ b/inttest/ct1/app.config
@@ -0,0 +1,2 @@
+%% This file is an application config file, not a CT test config file
+[{a1, [{foo, bar}]}].
diff --git a/inttest/ct1/ct1_rt.erl b/inttest/ct1/ct1_rt.erl
index f173d3f..f9de372 100644
--- a/inttest/ct1/ct1_rt.erl
+++ b/inttest/ct1/ct1_rt.erl
@@ -7,10 +7,12 @@ files() ->
[{create, "ebin/a1.app", app(a1)},
{copy, "../../rebar", "rebar"},
{copy, "rebar.config", "rebar.config"},
+ {copy, "app.config", "app.config"},
{copy, "test_SUITE.erl", "itest/test_SUITE.erl"}].
run(_Dir) ->
{ok, _} = retest:sh("./rebar compile ct"),
+ {ok, _} = retest:sh("./rebar compile ct -v"),
ok.
diff --git a/inttest/ct1/rebar.config b/inttest/ct1/rebar.config
index a4b5284..58047ba 100644
--- a/inttest/ct1/rebar.config
+++ b/inttest/ct1/rebar.config
@@ -1 +1,2 @@
{ct_dir, "itest"}.
+{ct_extra_params, "-repeat 2 -erl_args -config app"}.
diff --git a/inttest/ct1/test_SUITE.erl b/inttest/ct1/test_SUITE.erl
index 92f2b2e..e8a2bb8 100644
--- a/inttest/ct1/test_SUITE.erl
+++ b/inttest/ct1/test_SUITE.erl
@@ -5,7 +5,13 @@
-include_lib("ct.hrl").
all() ->
- [simple_test].
+ [simple_test,
+ app_config_file_test].
simple_test(Config) ->
io:format("Test: ~p\n", [Config]).
+
+app_config_file_test(_Config) ->
+ application:start(a1),
+ {ok, bar} = application:get_env(a1, foo),
+ application:stop(a1).
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl
index c075e8c..6bccb82 100644
--- a/src/rebar_ct.erl
+++ b/src/rebar_ct.erl
@@ -217,15 +217,13 @@ make_cmd(TestDir, RawLogDir, Config) ->
" ~s"
" ~s"
" -logdir \"~s\""
- " -env TEST_DIR \"~s\""
- " ~s",
+ " -env TEST_DIR \"~s\"",
[BaseCmd,
CodePathString,
Include,
build_name(Config),
LogDir,
- filename:join(Cwd, TestDir),
- get_extra_params(Config)]) ++
+ filename:join(Cwd, TestDir)]) ++
get_cover_config(Config, Cwd) ++
get_ct_config_file(TestDir) ++
get_config_file(TestDir) ++
@@ -237,19 +235,18 @@ make_cmd(TestDir, RawLogDir, Config) ->
" ~s"
" ~s"
" -logdir \"~s\""
- " -env TEST_DIR \"~s\""
- " ~s",
+ " -env TEST_DIR \"~s\"",
[BaseCmd,
CodePathString,
Include,
build_name(Config),
LogDir,
- filename:join(Cwd, TestDir),
- get_extra_params(Config)]) ++
+ filename:join(Cwd, TestDir)]) ++
SpecFlags ++ get_cover_config(Config, Cwd)
end,
+ Cmd1 = Cmd ++ get_extra_params(Config),
RawLog = filename:join(LogDir, "raw.log"),
- {Cmd, RawLog}.
+ {Cmd1, RawLog}.
build_name(Config) ->
case rebar_config:get_local(Config, ct_use_short_names, false) of
@@ -258,7 +255,12 @@ build_name(Config) ->
end.
get_extra_params(Config) ->
- rebar_config:get_local(Config, ct_extra_params, "").
+ case rebar_config:get_local(Config, ct_extra_params, undefined) of
+ undefined ->
+ "";
+ Defined ->
+ " " ++ Defined
+ end.
get_ct_specs(Config, Cwd) ->
case collect_glob(Config, Cwd, ".*\.test\.spec\$") of
diff --git a/src/rebar_shell.erl b/src/rebar_shell.erl
index 348e540..0220a79 100644
--- a/src/rebar_shell.erl
+++ b/src/rebar_shell.erl
@@ -41,10 +41,20 @@
shell(_Config, _AppFile) ->
true = code:add_pathz(rebar_utils:ebin_dir()),
+ %% scan all processes for any with references to the old user and save them to
+ %% update later
+ NeedsUpdate = [Pid || Pid <- erlang:processes(),
+ proplists:get_value(group_leader, erlang:process_info(Pid)) == whereis(user)
+ ],
%% terminate the current user
ok = supervisor:terminate_child(kernel_sup, user),
%% start a new shell (this also starts a new user under the correct group)
- user_drv:start(),
+ _ = user_drv:start(),
+ %% wait until user_drv and user have been registered (max 3 seconds)
+ ok = wait_until_user_started(3000),
+ %% set any process that had a reference to the old user's group leader to the
+ %% new user process
+ _ = [erlang:group_leader(whereis(user), Pid) || Pid <- NeedsUpdate],
%% enable error_logger's tty output
ok = error_logger:swap_handler(tty),
%% disable the simple error_logger (which may have been added multiple
@@ -56,9 +66,10 @@ shell(_Config, _AppFile) ->
info(help, shell) ->
?CONSOLE(
- "Start a shell with project and deps preloaded similar to~n"
- "'erl -pa ebin -pa deps/*/ebin'.~n",
- []).
+ "Start a shell with project and deps preloaded similar to~n"
+ "'erl -pa ebin -pa deps/*/ebin'.~n",
+ []
+ ).
remove_error_handler(0) ->
?WARN("Unable to remove simple error_logger handler~n", []);
@@ -66,4 +77,15 @@ remove_error_handler(N) ->
case gen_event:delete_handler(error_logger, error_logger, []) of
{error, module_not_found} -> ok;
{error_logger, _} -> remove_error_handler(N-1)
+ end.
+
+%% Timeout is a period to wait before giving up
+wait_until_user_started(0) ->
+ ?ABORT("Timeout exceeded waiting for `user` to register itself~n", []),
+ erlang:error(timeout);
+wait_until_user_started(Timeout) ->
+ case whereis(user) of
+ %% if user is not yet registered wait a tenth of a second and try again
+ undefined -> timer:sleep(100), wait_until_user_started(Timeout - 100);
+ _ -> ok
end. \ No newline at end of file