aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2015-09-09 14:51:11 +0200
committerSiri Hansen <[email protected]>2015-09-10 10:17:21 +0200
commit3a9a34e581494451cc798911477f3b7bc81e3492 (patch)
tree9be85266ebd778904294ea8513415c0b77ef36e8 /lib
parent1a1deb03240e7b1f738b8bc0fb172e6ae8e7061d (diff)
downloadotp-3a9a34e581494451cc798911477f3b7bc81e3492.tar.gz
otp-3a9a34e581494451cc798911477f3b7bc81e3492.tar.bz2
otp-3a9a34e581494451cc798911477f3b7bc81e3492.zip
Add test for "Fix cover output file"
If a module includes eunit.hrl, a parse transform adds the function test/0 on line 0 in the module. A bug in OTP-18.0 caused cover:analyse_to_file/1 to fail to insert cover data in the output file when line 0 existed in the cover data table. The bug is corrected by the commit "Fix cover output file". This commit adds a test which checks that the bug is not introduced again.
Diffstat (limited to 'lib')
-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.