aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reltool
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2012-03-12 17:34:15 +0100
committerSiri Hansen <[email protected]>2012-03-19 09:51:32 +0100
commitdac94945228322ffb9f8dd8495789c0cd64442a3 (patch)
treef029e91a1a637928e59229cb0d6bb3d15855a747 /lib/reltool
parent50bc03bf5cc4b55644d164819d8c58bef966e278 (diff)
downloadotp-dac94945228322ffb9f8dd8495789c0cd64442a3.tar.gz
otp-dac94945228322ffb9f8dd8495789c0cd64442a3.tar.bz2
otp-dac94945228322ffb9f8dd8495789c0cd64442a3.zip
[reltool] Just warn if same module occurs twice in .app file
OTP-9792 Earlier this would cause an error with reason "Module xxx potentially included by two different applications: yyy and yyy." This is now changed so it will only be a warning saying that the module is duplicated in the .app file.
Diffstat (limited to 'lib/reltool')
-rw-r--r--lib/reltool/src/reltool_server.erl40
-rw-r--r--lib/reltool/test/reltool_server_SUITE.erl40
-rw-r--r--lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app7
3 files changed, 70 insertions, 17 deletions
diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl
index d43be82cbd..29df619955 100644
--- a/lib/reltool/src/reltool_server.erl
+++ b/lib/reltool/src/reltool_server.erl
@@ -977,18 +977,32 @@ refresh_app(#app{name = AppName,
%% Add non-existing modules - i.e. create default #mod
%% records for all modules that are listed in .app file
%% but do not exist in ebin.
- AppInfoMods = AppInfo#app_info.modules,
- AppModNames =
- case AppInfo#app_info.mod of
- {StartModName, _} ->
- case lists:member(StartModName, AppInfoMods) of
- true -> AppInfoMods;
- false -> [StartModName | AppInfoMods]
- end;
- undefined ->
- AppInfoMods
- end,
- MissingMods = add_missing_mods(AppName, EbinMods, AppModNames),
+ AppInfoMods = lists:usort(AppInfo#app_info.modules),
+ Status4 =
+ case AppInfo#app_info.modules -- AppInfoMods of
+ [] ->
+ Status3;
+ DuplicatedMods ->
+ lists:foldl(
+ fun(M,S) ->
+ reltool_utils:add_warning(
+ "Module ~p duplicated in app file for "
+ "application ~p.", [M, AppName], S)
+ end,
+ Status3,
+ DuplicatedMods)
+ end,
+ AppModNames =
+ case AppInfo#app_info.mod of
+ {StartModName, _} ->
+ case lists:member(StartModName, AppInfoMods) of
+ true -> AppInfoMods;
+ false -> [StartModName | AppInfoMods]
+ end;
+ undefined ->
+ AppInfoMods
+ end,
+ MissingMods = add_missing_mods(AppName, EbinMods, AppModNames),
%% Add optional user config for each module.
%% The #mod records that are already in the #app record at
@@ -1013,7 +1027,7 @@ refresh_app(#app{name = AppName,
label = AppLabel,
info = AppInfo,
mods = lists:keysort(#mod.name, Mods3)},
- {App2, Status3};
+ {App2, Status4};
true ->
{App, Status}
end.
diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl
index 4b0511afaf..57b04251d4 100644
--- a/lib/reltool/test/reltool_server_SUITE.erl
+++ b/lib/reltool/test/reltool_server_SUITE.erl
@@ -69,8 +69,9 @@ all() ->
create_old_target,
eval_target_spec,
otp_9135,
- otp_9229_exclude_app,
- otp_9229_exclude_mod,
+ otp_9229_dupl_mod_exclude_app,
+ otp_9229_dupl_mod_exclude_mod,
+ dupl_mod_in_app_file,
get_apps,
get_mod,
get_sys,
@@ -1002,7 +1003,7 @@ eval_target_spec(_Config) ->
%% exists in two applications.
%% Include on app, exclude the other
-otp_9229_exclude_app(Config) ->
+otp_9229_dupl_mod_exclude_app(Config) ->
DataDir = ?config(data_dir,Config),
LibDir = filename:join(DataDir,"otp_9229"),
@@ -1049,7 +1050,7 @@ otp_9229_exclude_app(Config) ->
ok.
%% Include both apps, but exclude common module from one app
-otp_9229_exclude_mod(Config) ->
+otp_9229_dupl_mod_exclude_mod(Config) ->
DataDir = ?config(data_dir,Config),
LibDir = filename:join(DataDir,"otp_9229"),
@@ -1103,6 +1104,37 @@ otp_9229_exclude_mod(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Test that if a module is duplicated in a .app file, then a warning
+%% is produced, but target can still be created.
+dupl_mod_in_app_file(Config) ->
+ DataDir = ?config(data_dir,Config),
+ LibDir = filename:join(DataDir,"dupl_mod"),
+
+ %% Configure the server
+ Sys =
+ {sys,
+ [
+ {lib_dirs, [LibDir]},
+ {incl_cond,exclude},
+ {app,a,[{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_dupl_mod_in_app_file"]),
+ ?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,["Module a duplicated in app file for application a."]},
+ reltool:get_status([{config, Sys}])),
+
+ %%! test that only one module installed (in spec)
+
+ ok.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test the interface used by the GUI:
%% get_app
%% get_apps
diff --git a/lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app b/lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app
new file mode 100644
index 0000000000..fada34847a
--- /dev/null
+++ b/lib/reltool/test/reltool_server_SUITE_data/dupl_mod/a-1.0/ebin/a.app
@@ -0,0 +1,7 @@
+% -*-erlang-*-
+{application, a,
+ [{description, "Application with duplicated module name in .app file"},
+ {vsn, "1.0"},
+ {modules, [a,a]},
+ {registered, []},
+ {applications, [kernel, stdlib]}]}.