aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reltool
diff options
context:
space:
mode:
Diffstat (limited to 'lib/reltool')
-rw-r--r--lib/reltool/src/reltool_server.erl39
-rw-r--r--lib/reltool/src/reltool_utils.erl2
-rw-r--r--lib/reltool/test/reltool_server_SUITE.erl109
-rw-r--r--lib/reltool/test/reltool_test_lib.erl6
4 files changed, 132 insertions, 24 deletions
diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl
index 5e25f22a6f..97785ca7f8 100644
--- a/lib/reltool/src/reltool_server.erl
+++ b/lib/reltool/src/reltool_server.erl
@@ -973,7 +973,8 @@ refresh_app(#app{name = AppName,
is_escript = IsEscript,
active_dir = ActiveDir,
label = OptLabel,
- mods = Mods} = App,
+ mods = Mods,
+ status = AppStatus} = App,
Force,
Status) ->
if
@@ -993,6 +994,8 @@ refresh_app(#app{name = AppName,
read_app_info(AppFile,
AppFile,
AppName,
+ ActiveDir,
+ AppStatus,
DefaultVsn,
Status),
@@ -1064,9 +1067,11 @@ refresh_app(#app{name = AppName,
missing_app_info(Vsn) ->
#app_info{vsn = Vsn}.
-read_app_info(_AppFileOrBin, _AppFile, erts, DefaultVsn, Status) ->
+read_app_info(_AppFileOrBin, _AppFile, erts, _ActiveDir, _AppStatus, DefaultVsn, Status) ->
{missing_app_info(DefaultVsn), Status};
-read_app_info(AppFileOrBin, AppFile, AppName, DefaultVsn, Status) ->
+read_app_info(_AppFileOrBin, _AppFile, _AppName, undefined, missing, DefaultVsn, Status) ->
+ {missing_app_info(DefaultVsn), Status};
+read_app_info(AppFileOrBin, AppFile, AppName, _ActiveDir, _AppStatus, DefaultVsn, Status) ->
EnoentText = file:format_error(enoent),
case reltool_utils:prim_consult(AppFileOrBin) of
{ok, [{application, AppName, Info}]} ->
@@ -1080,9 +1085,9 @@ read_app_info(AppFileOrBin, AppFile, AppName, DefaultVsn, Status) ->
Status)};
{error, Text} when Text =:= EnoentText ->
{missing_app_info(DefaultVsn),
- reltool_utils:add_warning("~w: Missing app file ~tp.",
- [AppName,AppFile],
- Status)};
+ reltool_utils:add_warning("~w: Missing app file ~tp.",
+ [AppName,AppFile],
+ Status)};
{error, Text} ->
{missing_app_info(DefaultVsn),
reltool_utils:add_warning("~w: Cannot parse app file ~tp (~tp).",
@@ -1773,13 +1778,15 @@ escripts_to_apps([Escript | Escripts], Apps, Status) ->
get_vsn_from_dir(AppName,AppLabel),
AppFileName =
filename:join([Escript, FullName]),
+ Dir = filename:join([Escript, AppName]),
{Info, StatusAcc2} =
read_app_info(GetBin(),
AppFileName,
AppName,
+ Dir,
+ ok,
DefaultVsn,
Status),
- Dir = filename:join([Escript, AppName]),
{[{AppName, app, Dir, Info} | FileAcc],
StatusAcc2};
E when E =:= Ext ->
@@ -1979,20 +1986,27 @@ refresh_apps(ConfigApps, [New | NewApps], Acc, Force, Status) ->
refresh_apps(_ConfigApps, [], Acc, _Force, Status) ->
{lists:reverse(Acc), Status}.
-
ensure_app_info(#app{is_escript = IsEscript, active_dir = Dir, info = Info},
Status)
when IsEscript=/=false ->
%% Escript or application which is inlined in an escript
{Info, Dir, Status};
-ensure_app_info(#app{name = Name, sorted_dirs = []}, _Status) ->
- reltool_utils:throw_error("~w: : Missing application directory.",[Name]);
+ensure_app_info(#app{name = Name, sorted_dirs = []} = App, Status) ->
+ Reason = "~w: Missing application directory.",
+ case App of
+ #app{incl_cond = exclude, status = missing, active_dir = Dir} ->
+ Status2 = reltool_utils:add_warning(Reason, [Name], Status),
+ {missing_app_info(""), Dir, Status2};
+ _ ->
+ reltool_utils:throw_error(Reason, [Name])
+ end;
ensure_app_info(#app{name = Name,
vsn = Vsn,
use_selected_vsn = UseSelectedVsn,
active_dir = ActiveDir,
sorted_dirs = Dirs,
- info = undefined},
+ info = undefined,
+ status = AppStatus},
Status) ->
ReadInfo =
fun(Dir, StatusAcc) ->
@@ -2000,7 +2014,8 @@ ensure_app_info(#app{name = Name,
Ebin = filename:join([Dir, "ebin"]),
DefaultVsn = get_vsn_from_dir(Name,Base),
AppFile = filename:join([Ebin, atom_to_list(Name) ++ ".app"]),
- read_app_info(AppFile, AppFile, Name, DefaultVsn, StatusAcc)
+ read_app_info(AppFile, AppFile, Name, ActiveDir,
+ AppStatus, DefaultVsn, StatusAcc)
end,
{AllInfo, Status2} = lists:mapfoldl(ReadInfo, Status, Dirs),
AllVsns = [I#app_info.vsn || I <- AllInfo],
diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl
index edccb889b1..9af8f6bae8 100644
--- a/lib/reltool/src/reltool_utils.erl
+++ b/lib/reltool/src/reltool_utils.erl
@@ -572,7 +572,7 @@ copy_file(From, To) ->
FromMode = FromInfo#file_info.mode,
ToMode = ToInfo#file_info.mode,
ToMode2 = FromMode bor ToMode,
- FileInfo = FromInfo#file_info{mode = ToMode2},
+ FileInfo = ToInfo#file_info{mode = ToMode2},
write_file_info(To, FileInfo),
ok;
{error, Reason} ->
diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl
index 23338d9ecd..752037042d 100644
--- a/lib/reltool/test/reltool_server_SUITE.erl
+++ b/lib/reltool/test/reltool_server_SUITE.erl
@@ -28,6 +28,7 @@
-include_lib("reltool/src/reltool.hrl").
-include("reltool_test_lib.hrl").
-include_lib("common_test/include/ct.hrl").
+-include_lib("kernel/include/file.hrl").
-define(NODE_NAME, '__RELTOOL__TEMPORARY_TEST__NODE__').
-define(WORK_DIR, "reltool_work_dir").
@@ -36,8 +37,9 @@
%% Initialization functions.
init_per_suite(Config) ->
+ {ok,Cwd} = file:get_cwd(),
?ignore(file:make_dir(?WORK_DIR)),
- reltool_test_lib:init_per_suite(Config).
+ [{cwd,Cwd}|reltool_test_lib:init_per_suite(Config)].
end_per_suite(Config) ->
reltool_test_lib:end_per_suite(Config).
@@ -49,9 +51,49 @@ init_per_testcase(Func,Config) ->
pang -> ok
end,
reltool_test_lib:init_per_testcase(Func,Config).
-end_per_testcase(Func,Config) ->
+end_per_testcase(Func,Config) ->
+ ok = file:set_cwd(filename:join(?config(cwd,Config),?WORK_DIR)),
+ {ok,All} = file:list_dir("."),
+ Files = [F || F <- All, false == lists:prefix("save.",F)],
+ case ?config(tc_status,Config) of
+ ok ->
+ ok;
+ _Fail ->
+ SaveDir = "save."++atom_to_list(Func),
+ ok = file:make_dir(SaveDir),
+ save_test_result(Files,SaveDir)
+ end,
+ rm_files(Files),
+ ok = file:set_cwd(?config(cwd,Config)),
reltool_test_lib:end_per_testcase(Func,Config).
+
+save_test_result(Files,DestDir) ->
+ Tar = "copy.tar",
+ ok = erl_tar:create(Tar, Files),
+ ok = erl_tar:extract(Tar, [{cwd,DestDir}]),
+ ok = file:delete(Tar),
+ ok.
+
+rm_files([F | Fs]) ->
+ case file:read_file_info(F) of
+ {ok,#file_info{type=directory}} ->
+ rm_dir(F);
+ {ok,_Regular} ->
+ ok = file:delete(F)
+ end,
+ rm_files(Fs);
+rm_files([]) ->
+ ok.
+
+rm_dir(Dir) ->
+ {ok,Files} = file:list_dir(Dir),
+ rm_files([filename:join(Dir, F) || F <- Files]),
+ ok = file:del_dir(Dir).
+
+
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SUITE specification
@@ -80,6 +122,8 @@ all() ->
otp_9229_dupl_mod_exclude_app,
otp_9229_dupl_mod_exclude_mod,
dupl_mod_in_app_file,
+ include_non_existing_app,
+ exclude_non_existing_app,
get_apps,
get_mod,
get_sys,
@@ -504,7 +548,7 @@ create_script(_Config) ->
%% ?m(OrigScript2, Script2),
?m(equal, diff_script(OrigScript, Script)),
-
+
%% Stop server
?m(ok, reltool:stop(Pid)),
ok.
@@ -753,7 +797,7 @@ create_target(_Config) ->
Erl = filename:join([TargetDir, "bin", "erl"]),
{ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)),
?msym(ok, stop_node(Node)),
-
+
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1313,7 +1357,6 @@ otp_9229_dupl_mod_exclude_mod(Config) ->
ok.
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test that if a module is duplicated in a .app file, then a warning
%% is produced, but target can still be created.
@@ -1346,6 +1389,56 @@ dupl_mod_in_app_file(Config) ->
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Test that a reasonable error message is returned if an application
+%% is missing
+include_non_existing_app(_Config) ->
+ %% Configure the server
+ Sys =
+ {sys,
+ [
+ {incl_cond,exclude},
+ {app,foobar,[{incl_cond,include}]},
+ {app,kernel,[{incl_cond,include}]},
+ {app,stdlib,[{incl_cond,include}]},
+ {app,sasl,[{incl_cond,include}]}
+ ]},
+
+ %% Generate target file
+ TargetDir = filename:join([?WORK_DIR, "target_include_non_existing_app"]),
+ ?m(ok, reltool_utils:recursive_delete(TargetDir)),
+ ?m(ok, file:make_dir(TargetDir)),
+ ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, Sys}])]),
+ ?m({error,"foobar: Missing application directory."},
+ reltool:get_status([{config, Sys}])),
+
+ ok.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Test that if a missing application is explicitly excluded a warning
+%% should be issued.
+exclude_non_existing_app(_Config) ->
+ %% Configure the server
+ Sys =
+ {sys,
+ [
+ {incl_cond,exclude},
+ {app,foobar,[{incl_cond,exclude}]},
+ {app,kernel,[{incl_cond,include}]},
+ {app,stdlib,[{incl_cond,include}]},
+ {app,sasl,[{incl_cond,include}]}
+ ]},
+
+ %% Generate target file
+ TargetDir = filename:join([?WORK_DIR, "target_exclude_non_existing_app"]),
+ ?m(ok, reltool_utils:recursive_delete(TargetDir)),
+ ?m(ok, file:make_dir(TargetDir)),
+ ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, Sys}])]),
+ ?m({ok,["foobar: Missing application directory."]},
+ reltool:get_status([{config, Sys}])),
+
+ ok.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test the interface used by the GUI:
%% get_app
%% get_apps
@@ -2502,8 +2595,8 @@ start_node(Name, ErlPath, Args0) ->
%io:format("open_port({spawn_executable, ~p}, [{args,~p}])~n",[ErlPath,Args]),
case open_port({spawn_executable, ErlPath}, [{args,Args}]) of
Port when is_port(Port) ->
- unlink(Port),
- erlang:port_close(Port),
+ %% no need to close port since node is detached (see
+ %% mk_node_args) so port will be closed anyway.
case ping_node(FullName, 50) of
ok -> {ok, FullName};
Other -> exit({failed_to_start_node, FullName, Other})
@@ -2536,7 +2629,7 @@ mk_node_args(Name, Args) ->
end,
{ok, Pwd} = file:get_cwd(),
NameStr = atom_to_list(Name),
- ["-detached", "-noinput",
+ ["-detached",
NameSw, NameStr,
"-pa", Pa,
"-env", "ERL_CRASH_DUMP", Pwd ++ "/erl_crash_dump." ++ NameStr,
diff --git a/lib/reltool/test/reltool_test_lib.erl b/lib/reltool/test/reltool_test_lib.erl
index 61f783190c..3485365ed9 100644
--- a/lib/reltool/test/reltool_test_lib.erl
+++ b/lib/reltool/test/reltool_test_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -25,7 +25,7 @@
init_per_suite(Config) when is_list(Config)->
global:register_name(reltool_global_logger, group_leader()),
- incr_timetrap(Config, 5).
+ incr_timetrap(Config, 10).
end_per_suite(Config) when is_list(Config)->
global:unregister_name(reltool_global_logger),
@@ -51,7 +51,7 @@ set_kill_timer(Config) ->
Time =
case lookup_config(tc_timeout, Config) of
[] ->
- timer:minutes(5);
+ timer:minutes(10);
ConfigTime when is_integer(ConfigTime) ->
ConfigTime
end,