summaryrefslogtreecommitdiff
path: root/lib/tools
diff options
context:
space:
mode:
authorMikael Pettersson <mikpelinux@gmail.com>2021-05-04 20:02:06 +0200
committerMikael Pettersson <mikpelinux@gmail.com>2021-05-20 15:58:23 +0200
commite28e11b5af0fa552ea46adf1210adf7933834077 (patch)
tree8955120b1d872c8f027d261a7f1e55095fc56899 /lib/tools
parente81d0f5a572ac3637d08064620460fa5b2a229c1 (diff)
downloaderlang-e28e11b5af0fa552ea46adf1210adf7933834077.tar.gz
cover:filter_options/1: preserve tuple_calls
Diffstat (limited to 'lib/tools')
-rw-r--r--lib/tools/src/cover.erl1
-rw-r--r--lib/tools/test/cover_SUITE.erl25
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl
index 9964d8ce19..f9de2077e3 100644
--- a/lib/tools/src/cover.erl
+++ b/lib/tools/src/cover.erl
@@ -335,6 +335,7 @@ filter_options(Options) ->
{d, _Macro} -> true;
{d, _Macro, _Value} -> true;
export_all -> true;
+ tuple_calls -> true;
_ -> false
end
end,
diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl
index b9cd028546..2bf86f733b 100644
--- a/lib/tools/test/cover_SUITE.erl
+++ b/lib/tools/test/cover_SUITE.erl
@@ -32,7 +32,7 @@ all() ->
otp_8340,otp_8188,compile_beam_opts,eep37,
analyse_no_beam, line_0, compile_beam_no_file,
compile_beam_missing_backend,
- otp_13277, otp_13289, guard_in_lc],
+ otp_13277, otp_13289, guard_in_lc, gh_4796],
StartStop = [start, compile, analyse, misc, stop,
distribution, reconnect, die_and_reconnect,
dont_reconnect_after_stop, stop_node_after_disconnect,
@@ -1877,6 +1877,24 @@ otp_16476(Config) when is_list(Config) ->
ok = cover:stop(),
ok.
+%% GH-4796: failure to preserve tuple_calls compiler option
+gh_4796(Config) ->
+ Test = <<"-module(gh_4796).
+ -export([test/0, foo/1]).
+
+ test() ->
+ PMod = new(42),
+ PMod:foo().
+
+ new(X) -> {?MODULE, X}.
+
+ foo({?MODULE, 42}) -> ok.
+ ">>,
+ File = c_mod(gh_4796, Test, Config, [tuple_calls]),
+ {ok, gh_4796} = cover:compile_beam(gh_4796),
+ ok = file:delete(File),
+ ok = gh_4796:test().
+
%%--Auxiliary------------------------------------------------------------
analyse_expr(Expr, Config) ->
@@ -1902,13 +1920,16 @@ cc_mod(M, Binary, Config) ->
end.
c_mod(M, Binary, Config) ->
+ c_mod(M, Binary, Config, _CompileOpts = []).
+
+c_mod(M, Binary, Config, CompileOpts) ->
{ok, Dir} = file:get_cwd(),
PrivDir = proplists:get_value(priv_dir, Config),
ok = file:set_cwd(PrivDir),
File = atom_to_list(M) ++ ".erl",
try
ok = file:write_file(File, Binary),
- {ok, M} = compile:file(File, [debug_info]),
+ {ok, M} = compile:file(File, CompileOpts ++ [debug_info]),
code:purge(M),
AbsFile = filename:rootname(File, ".erl"),
code:load_abs(AbsFile, M),