aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tools/test')
-rw-r--r--lib/tools/test/cover_SUITE.erl24
-rw-r--r--lib/tools/test/cover_SUITE_data/include_eunit_hrl/cover_inc_eunit.erl6
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl
index 931e3e2cfa..25c9317608 100644
--- a/lib/tools/test/cover_SUITE.erl
+++ b/lib/tools/test/cover_SUITE.erl
@@ -31,7 +31,7 @@
otp_5031/1, eif/1, otp_5305/1, otp_5418/1, otp_6115/1, otp_7095/1,
otp_8188/1, otp_8270/1, otp_8273/1, otp_8340/1,
otp_10979_hanging_node/1, compile_beam_opts/1, eep37/1,
- analyse_no_beam/1]).
+ analyse_no_beam/1, line_0/1]).
-export([do_coverage/1]).
@@ -55,7 +55,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
NoStartStop = [eif,otp_5305,otp_5418,otp_7095,otp_8273,
otp_8340,otp_8188,compile_beam_opts,eep37,
- analyse_no_beam],
+ analyse_no_beam, line_0],
StartStop = [start, compile, analyse, misc, stop,
distribution, reconnect, die_and_reconnect,
dont_reconnect_after_stop, stop_node_after_disconnect,
@@ -1727,6 +1727,26 @@ analyse_no_beam(Config) when is_list(Config) ->
ok = file:set_cwd(Cwd),
ok.
+%% When including eunit.hrl, a parse transform adds the function
+%% test/0 to line 0 in your module. A bug in OTP-18.0 caused
+%% cover:analyse_to_file/1 to fail to insert cover data in the output
+%% file in this situation. The test below tests that this bug is
+%% corrected.
+line_0(Config) ->
+ ok = file:set_cwd(filename:join(?config(data_dir, Config),
+ "include_eunit_hrl")),
+ {ok, cover_inc_eunit} = compile:file(cover_inc_eunit,[debug_info]),
+ {ok, cover_inc_eunit} = cover:compile_beam(cover_inc_eunit),
+ {ok, CovOut} = cover:analyse_to_file(cover_inc_eunit),
+
+ {ok,Bin} = file:read_file(CovOut),
+ Match = <<"0..| ok.\n">>, % "0.." is missing when bug is there
+ S = byte_size(Bin)-byte_size(Match),
+ <<_:S/binary,Match/binary>> = Bin,
+ ok.
+
+
+
%%--Auxiliary------------------------------------------------------------
analyse_expr(Expr, Config) ->
diff --git a/lib/tools/test/cover_SUITE_data/include_eunit_hrl/cover_inc_eunit.erl b/lib/tools/test/cover_SUITE_data/include_eunit_hrl/cover_inc_eunit.erl
new file mode 100644
index 0000000000..c1fe7939d2
--- /dev/null
+++ b/lib/tools/test/cover_SUITE_data/include_eunit_hrl/cover_inc_eunit.erl
@@ -0,0 +1,6 @@
+-module(cover_inc_eunit).
+-compile(export_all).
+-include_lib("eunit/include/eunit.hrl").
+
+func() ->
+ ok.