GNU bug report logs - #25471
26.0.50; Edebug and Testcover give incorrect code coverage results for code that uses 'unknown

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Gemini Lasswell <gazally@HIDDEN>; dated Tue, 17 Jan 2017 21:26:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 25471 <at> debbugs.gnu.org:


Received: (at 25471) by debbugs.gnu.org; 27 Jul 2019 10:30:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 27 06:30:56 2019
Received: from localhost ([127.0.0.1]:43637 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hrJyZ-0006I4-OX
	for submit <at> debbugs.gnu.org; Sat, 27 Jul 2019 06:30:55 -0400
Received: from quimby.gnus.org ([80.91.231.51]:35718)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1hrJyX-0006Hw-TR
 for 25471 <at> debbugs.gnu.org; Sat, 27 Jul 2019 06:30:54 -0400
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie)
 by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.89) (envelope-from <larsi@HIDDEN>)
 id 1hrJyT-0006Fj-Fb; Sat, 27 Jul 2019 12:30:51 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Gemini Lasswell <gazally@HIDDEN>
Subject: Re: bug#25471: 26.0.50; Edebug and Testcover give incorrect code
 coverage results for code that uses 'unknown
References: <m28tq97538.fsf@HIDDEN>
Date: Sat, 27 Jul 2019 12:30:49 +0200
In-Reply-To: <m28tq97538.fsf@HIDDEN> (Gemini Lasswell's message of
 "Tue, 17 Jan 2017 13:24:11 -0800")
Message-ID: <874l37lqg6.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Gemini Lasswell <gazally@HIDDEN> writes: > If you use
 Edebug or Testcover to gather code coverage information on > code which uses
 the symbol `unknown', you will get incorrect code > coverage results, because
 Edebug uses `unknown' internally [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 25471
Cc: 25471 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Gemini Lasswell <gazally@HIDDEN> writes:

> If you use Edebug or Testcover to gather code coverage information on
> code which uses the symbol `unknown', you will get incorrect code
> coverage results, because Edebug uses `unknown' internally to represent
> forms which have never been evaluated under Edebug.

I've now fixed this in edebug.el on the trunk.

> For an example of incorrect code coverage, save this function definition
> in a file called bug.el:
>
> (defun how-do-i-know-you (name)
>   (let ((val 'unknown))
>     (when (equal name "Bob")
>       (setq val 'known))
>     val))
>
> And then use:
>
> M-x testcover-start RET bug.el RET
> M-: (how-do-i-know-you "Liz") RET
> M-x testcover-mark-all RET RET

However, the testcover case seems to be more complicated.  `unknown'
seems straightforward, but there's also `1value' and `maybe' and perhaps
some other symbols that I'm not sure need this or not.  `noreturn', for
instance, seems part of the official API and can't be changed...  I
think?

I don't use testcover myself.  Could you perhaps propose a patch to fix
this?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#25471; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jan 2017 21:25:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 17 16:25:09 2017
Received: from localhost ([127.0.0.1]:34112 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cTbFd-00024W-CI
	for submit <at> debbugs.gnu.org; Tue, 17 Jan 2017 16:25:09 -0500
Received: from eggs.gnu.org ([208.118.235.92]:48935)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gazally@HIDDEN>) id 1cTbFb-00024I-Te
 for submit <at> debbugs.gnu.org; Tue, 17 Jan 2017 16:25:08 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1cTbFV-0006Ux-Ub
 for submit <at> debbugs.gnu.org; Tue, 17 Jan 2017 16:25:02 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:52841)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <gazally@HIDDEN>) id 1cTbFV-0006Uo-SO
 for submit <at> debbugs.gnu.org; Tue, 17 Jan 2017 16:25:01 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39887)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1cTbFU-0006fs-IM
 for bug-gnu-emacs@HIDDEN; Tue, 17 Jan 2017 16:25:01 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1cTbFQ-0006Qe-GT
 for bug-gnu-emacs@HIDDEN; Tue, 17 Jan 2017 16:25:00 -0500
Received: from aibo.runbox.com ([91.220.196.211]:45045)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <gazally@HIDDEN>) id 1cTbFQ-0006O6-9O
 for bug-gnu-emacs@HIDDEN; Tue, 17 Jan 2017 16:24:56 -0500
Received: from [10.9.9.210] (helo=mailfront10.runbox.com)
 by bars.runbox.com with esmtp (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1cTbFM-0004ru-Pb
 for bug-gnu-emacs@HIDDEN; Tue, 17 Jan 2017 22:24:52 +0100
Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161]
 helo=rainbow.local)
 by mailfront10.runbox.com with esmtpsa (uid:179284 )
 (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1cTbF6-00046Z-PO
 for bug-gnu-emacs@HIDDEN; Tue, 17 Jan 2017 22:24:37 +0100
From: Gemini Lasswell <gazally@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 26.0.50;
 Edebug and Testcover give incorrect code coverage results for code
 that uses 'unknown
Date: Tue, 17 Jan 2017 13:24:11 -0800
Message-ID: <m28tq97538.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)

If you use Edebug or Testcover to gather code coverage information on
code which uses the symbol `unknown', you will get incorrect code
coverage results, because Edebug uses `unknown' internally to represent
forms which have never been evaluated under Edebug.

`unknown' is an obvious name for a Lisp symbol and is used in the Emacs
sources in cedet, calc, cus-edit, elint, erc, gnus and several other
places.

For an example of incorrect code coverage, save this function definition
in a file called bug.el:

(defun how-do-i-know-you (name)
  (let ((val 'unknown))
    (when (equal name "Bob")
      (setq val 'known))
    val))

And then use:

M-x testcover-start RET bug.el RET
M-: (how-do-i-know-you "Liz") RET
M-x testcover-mark-all RET RET

The result will be red splotches on the last line of how-do-i-know-you
indicating that Testcover thinks it was never executed.

This could be very simply fixed by changing Edebug to use
`edebug-unknown' instead. The other symbols currently used to record
code coverage are `1value' and `ok-coverage', and they could be changed
respectively to `testcover-1value' and `edebug-ok-coverage'. edebug.el
and testcover.el still wouldn't be able to do code coverage on
themselves, but they should then work for everybody else.




Acknowledgement sent to Gemini Lasswell <gazally@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#25471; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.