Skip to content

Commit

Permalink
Merge branch 'bjorn/test-cuddling'
Browse files Browse the repository at this point in the history
* bjorn/test-cuddling:
  incremental_SUITE: Eliminate test failure on Windows
  • Loading branch information
bjorng committed Nov 7, 2022
2 parents c061907 + 07c6593 commit 117f4e3
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions lib/dialyzer/test/incremental_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -731,32 +731,14 @@ default_apps_config_xdg(Config) ->
case os:type() of
{win32, _} ->
[Drive | Path] = filename:split(TestHome),
[{"APPDATA", filename:join(TestHome,"AppData")},
{"HOMEDRIVE", Drive}, {"HOMEPATH", Path}];
[{"APPDATA", filename:join(TestHome, "AppData")},
{"HOMEDRIVE", Drive},
{"HOMEPATH", filename:join(Path)}];
_ ->
[{"HOME", TestHome}]
end,

%% We add in the default subdirs used for each system
%% to store config within the home directory
ConfigSubDirs =
case os:type() of
{unix, darwin} ->
["Library","Application Support"];
{win32, _} ->
[];
_ ->
[".config"]
end,

HomeConfigFilename =
filename:join([TestHome] ++ ConfigSubDirs ++ ["erlang", "dialyzer.config"]),
ok = filelib:ensure_dir(HomeConfigFilename),

HomeConfig =
{incremental, {default_apps, [stdlib, kernel, erts, compiler, mnesia, ftp]}},

ok = file:write_file(HomeConfigFilename, io_lib:format("~p.~n", [HomeConfig])),
io:format("~p\n", [HomeEnv]),

PrivDir = ?config(priv_dir, Config),
PltFile = filename:join(PrivDir, atom_to_list(?FUNCTION_NAME) ++ ".iplt"),
Expand All @@ -766,17 +748,32 @@ default_apps_config_xdg(Config) ->
erpc:call(
Node,
fun() ->
_ = dialyzer:run([{analysis_type, incremental},
{init_plt,PltFile},
{output_plt, PltFile}]),
{ok, {incremental, [{modules, Modules}]}} = dialyzer:plt_info(PltFile),

ExpectedModules = [gb_sets, erlang, compile, mnesia, ftp],

% Assert PLT info contains modules from the apps given in the config
?assertMatch([], sets:to_list(sets:subtract(
sets:from_list(ExpectedModules),
sets:from_list(Modules))))
%% Find out the path of the config file
HomeConfigFilename =
filename:join(filename:basedir(user_config, "erlang"),
"dialyzer.config"),
io:format("~ts\n", [HomeConfigFilename]),
ok = filelib:ensure_dir(HomeConfigFilename),

%% Write configuration file
HomeConfig =
{incremental, {default_apps, [stdlib, kernel, erts,
compiler, mnesia, ftp]}},
ok = file:write_file(HomeConfigFilename,
io_lib:format("~p.~n", [HomeConfig])),

%% Run dialyzer and check result
_ = dialyzer:run([{analysis_type, incremental},
{init_plt,PltFile},
{output_plt, PltFile}]),
{ok, {incremental, [{modules, Modules}]}} = dialyzer:plt_info(PltFile),

ExpectedModules = [gb_sets, erlang, compile, mnesia, ftp],

%% Assert PLT info contains modules from the apps given in the config
?assertMatch([], ordsets:subtract(
ordsets:from_list(ExpectedModules),
ordsets:from_list(Modules)))
end),

peer:stop(Peer).
Expand Down

0 comments on commit 117f4e3

Please sign in to comment.