diff options
author | Siri Hansen <siri@erlang.org> | 2012-01-04 16:09:01 +0100 |
---|---|---|
committer | Siri Hansen <siri@erlang.org> | 2012-03-19 09:48:53 +0100 |
commit | 40014d4b190c86044df5f1aa70dad7138d531b7b (patch) | |
tree | c691b431232fe7c8e44bdf1d50dd04ae9d563ef9 /lib/reltool/src | |
parent | 3087769515ea9bfc75f7d7b8897bc897c7f13931 (diff) | |
download | otp-40014d4b190c86044df5f1aa70dad7138d531b7b.tar.gz otp-40014d4b190c86044df5f1aa70dad7138d531b7b.tar.bz2 otp-40014d4b190c86044df5f1aa70dad7138d531b7b.zip |
[reltool] Add more test cases and fix bugs
OTP-9794
The following test cases are added for the inteface from GUI to
reltool_server:
* get_config
* get_apps
* set_app_and_undo
* set_apps_and_undo
* load_config_and_undo
* reset_config_and_undo
* save_config
The following bugs were found and corrected:
* If set_apps failed, then the state of reltool_server would not
be reset to how it was before the failing operation - and every
operation done afterwards would also (seem to) fail.
* undo_config did not work after reset_config - since faulty #sys
record was stored as old_sys.
* undo_config did not work after set_app (used when changing the
content of an application from the GUI) - since old_sys was not
set. Also old_status was not set causing possible warnings to
disappear.
* undo_config did not work after set_apps (used e.g. when
excluding or including an application from the GUI) - since
old_sys was not set. Also old_status was not set causing
possible warnings to disappear.
Diffstat (limited to 'lib/reltool/src')
-rw-r--r-- | lib/reltool/src/reltool.hrl | 6 | ||||
-rw-r--r-- | lib/reltool/src/reltool_server.erl | 59 |
2 files changed, 36 insertions, 29 deletions
diff --git a/lib/reltool/src/reltool.hrl b/lib/reltool/src/reltool.hrl index 93f47f6381..8e80c80e10 100644 --- a/lib/reltool/src/reltool.hrl +++ b/lib/reltool/src/reltool.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2011. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. 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 @@ -199,8 +199,8 @@ used_by_mods :: [mod_name()], uses_apps :: [app_name()], used_by_apps :: [app_name()], - is_pre_included :: boolean(), - is_included :: boolean(), + is_pre_included :: boolean() | undefined, + is_included :: boolean() | undefined, rels :: [rel_name()] }). diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl index 692baea0a4..fdb9e08a90 100644 --- a/lib/reltool/src/reltool_server.erl +++ b/lib/reltool/src/reltool_server.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2011. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. 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 @@ -254,7 +254,7 @@ loop(#state{common = C, sys = Sys} = S) -> {S2, Status} = parse_options(S#state.options), S3 = shrink_sys(S2), {S4, Status2} = refresh(S3, true, Status), - {S5, Status3} = analyse(S4#state{old_sys = S4#state.sys}, Status2), + {S5, Status3} = analyse(S4#state{old_sys = S#state.sys}, Status2), S6 = case Status3 of {ok, _Warnings} -> @@ -266,11 +266,11 @@ loop(#state{common = C, sys = Sys} = S) -> reltool_utils:reply(ReplyTo, Ref, Status3), ?MODULE:loop(S6); {call, ReplyTo, Ref, undo_config} -> - reltool_utils:reply(ReplyTo, Ref, ok), S2 = S#state{sys = S#state.old_sys, old_sys = S#state.sys, status = S#state.old_status, old_status = S#state.status}, + reltool_utils:reply(ReplyTo, Ref, ok), ?MODULE:loop(S2); {call, ReplyTo, Ref, {get_rel, RelName}} -> Sys = S#state.sys, @@ -319,19 +319,21 @@ loop(#state{common = C, sys = Sys} = S) -> ?MODULE:loop(S); {call, ReplyTo, Ref, {set_app, App}} -> {S2, Status} = do_set_app(S, App, {ok, []}), - {S3, Status2} = analyse(S2, Status), - case Status2 of - {ok, Warnings} -> - App2 = ?KEYSEARCH(App#app.name, - #app.name, - (S3#state.sys)#sys.apps), - reltool_utils:reply(ReplyTo, Ref, {ok, App2, Warnings}), - ?MODULE:loop(S3); - {error, Reason} -> - %% Keep old state - reltool_utils:reply(ReplyTo, Ref, {error, Reason}), - ?MODULE:loop(S) - end; + {S3, Status2} = analyse(S2#state{old_sys=S#state.sys}, Status), + {S4, Reply} = + case Status2 of + {ok, Warnings} -> + App2 = ?KEYSEARCH(App#app.name, + #app.name, + (S3#state.sys)#sys.apps), + {S3#state{status=Status2, old_status=S#state.status}, + {ok, App2, Warnings}}; + {error, _} -> + %% Keep old state + {S, Status2} + end, + reltool_utils:reply(ReplyTo, Ref, Reply), + ?MODULE:loop(S4); {call, ReplyTo, Ref, {get_apps, Kind}} -> AppNames = case Kind of @@ -361,9 +363,17 @@ loop(#state{common = C, sys = Sys} = S) -> lists:foldl(fun(A, {X, Y}) -> do_set_app(X, A, Y) end, {S, {ok, []}}, Apps), - {S3, Status2} = analyse(S2, Status), + {S3, Status2} = analyse(S2#state{old_sys = S#state.sys}, Status), + S4 = + case Status2 of + {ok, _Warnings} -> + S3#state{status=Status2, old_status=S#state.status}; + {error, _} -> + %% Keep old state + S + end, reltool_utils:reply(ReplyTo, Ref, Status2), - ?MODULE:loop(S3); + ?MODULE:loop(S4); {call, ReplyTo, Ref, get_sys} -> reltool_utils:reply(ReplyTo, Ref, {ok, Sys#sys{apps = undefined}}), ?MODULE:loop(S); @@ -374,19 +384,16 @@ loop(#state{common = C, sys = Sys} = S) -> (Sys2#sys.lib_dirs =/= Sys#sys.lib_dirs) orelse (Sys2#sys.escripts =/= Sys#sys.escripts), {S3, Status} = refresh(S2, Force, {ok, []}), - {S4, Status2} = - analyse(S3#state{old_sys = S#state.sys}, Status), - {S5, Status3} = + {S4, Status2} = analyse(S3#state{old_sys = S#state.sys}, Status), + S5 = case Status2 of {ok, _Warnings} -> % BUGBUG: handle warnings - {S4#state{status = Status2, - old_status = S#state.status}, - Status2}; + S4#state{status = Status2, old_status = S#state.status}; {error, _} -> %% Keep old state - {S, Status2} + S end, - reltool_utils:reply(ReplyTo, Ref, Status3), + reltool_utils:reply(ReplyTo, Ref, Status2), ?MODULE:loop(S5); {call, ReplyTo, Ref, get_status} -> reltool_utils:reply(ReplyTo, Ref, S#state.status), |