You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/01/08 02:47:38 UTC

[couchdb-rebar] branch main updated: Relax ANNO limitation in test coverage utils

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-rebar.git


The following commit(s) were added to refs/heads/main by this push:
     new 5582379  Relax ANNO limitation in test coverage utils
5582379 is described below

commit 5582379a8e2a250eadb146d8b8c9f82c1b32e732
Author: Jay Doane <ja...@apache.org>
AuthorDate: Sat Jan 7 15:49:59 2023 -0800

    Relax ANNO limitation in test coverage utils
    
    Currently the code to determine whether a particular file attribute
    ("header") exists assumes an ANNO format of a single line number, but
    versions of OTP > 23 return a tuple, so that pattern will never match,
    resulting in coverage failing to account for the inclusion of the
    `eunit.hrl` file, and then incorrectly calculating the coverage of the
    test module as 66%, rather than the expected 100%.
    
    This change relaxes the pattern so that it will also match tuples,
    and fixes the eunit coverage test.
    
    See also: https://github.com/apache/couchdb-rebar/pull/5
---
 src/rebar_cover_utils.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rebar_cover_utils.erl b/src/rebar_cover_utils.erl
index 7b85f1c..cb50c0c 100644
--- a/src/rebar_cover_utils.erl
+++ b/src/rebar_cover_utils.erl
@@ -184,7 +184,7 @@ has_header(Mod, Header) ->
            end,
     {ok, {_, [{abstract_code, {_, AC}}]}} =
         beam_lib:chunks(Mod1, [abstract_code]),
-    [F || {attribute, 1, file, {F, 1}} <- AC,
+    [F || {attribute, _, file, {F, 1}} <- AC,
           string:str(F, Header) =/= 0] =/= [].
 
 align_notcovered_count(Module, Covered, NotCovered, false) ->