From unknown Thu Aug 14 21:51:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them Resent-From: Gemini Lasswell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Jan 2017 03:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25351 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 25351@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14834992028849 (code B ref -1); Wed, 04 Jan 2017 03:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Jan 2017 03:06:42 +0000 Received: from localhost ([127.0.0.1]:40695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cObuT-0002If-Pt for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:41 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cObuR-0002IT-Vp for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cObuM-0000c7-1C for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:34 -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]:47614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cObuL-0000c3-UM for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cObuI-0006lh-8J for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 22:06:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cObuD-0000Yh-7z for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 22:06:30 -0500 Received: from aibo.runbox.com ([91.220.196.211]:43220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cObuD-0000XU-0g for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 22:06:25 -0500 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1cObuA-0006Cx-U4 for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 04:06:22 +0100 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=rainbow.local) by mailfront11.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1cObu7-0001bE-Ob for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 04:06:20 +0100 From: Gemini Lasswell Date: Tue, 03 Jan 2017 19:06:17 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) Testcover marks forms which have only returned a single value while under code coverage with a tan splotch to indicate insufficient test coverage, It also identifies forms which will only ever return a single value and suppresses the splotch on those. During the coverage run, it saves a reference to the return value of those single value forms, and the next time the form is evaluated, it uses `equal' to determine if the value has changed, and if it has, Testcover reports an error. The problem with this is that it is a common idiom to create a data structure using an expression that always returns the same thing, and then modify it later. Since Testcover keeps a reference not a copy, it ends up with a reference to a modified object, which fails the comparison with the next return value of the same expression. For example: (defun my-blank-record () (list (list 'name) (list 'age))) (defun my-make-record (name age) (let ((rec (my-blank-record))) (setf (cdr (assq 'name rec)) name) (setf (cdr (assq 'age rec)) age) rec)) (my-make-record "Jack" 10) (my-make-record "Jill" 12) To reproduce this problem, save the above code in a file called bug.el, and then: M-x testcover-start RET bug.el RET The result will be testcover-1value's "Value of form marked with =E2=80=981value=E2=80=99 does vary" error. From unknown Thu Aug 14 21:51:29 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25351: Patch for bug#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them Resent-From: Gemini Lasswell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Sep 2017 21:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25351 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 25351@debbugs.gnu.org Received: via spool by 25351-submit@debbugs.gnu.org id=B25351.15064599133163 (code B ref 25351); Tue, 26 Sep 2017 21:06:01 +0000 Received: (at 25351) by debbugs.gnu.org; 26 Sep 2017 21:05:13 +0000 Received: from localhost ([127.0.0.1]:33703 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwx2X-0000ox-GI for submit@debbugs.gnu.org; Tue, 26 Sep 2017 17:05:13 -0400 Received: from aibo.runbox.com ([91.220.196.211]:56398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwx2U-0000oo-OF for 25351@debbugs.gnu.org; Tue, 26 Sep 2017 17:05:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=UompqiCyt8gnEhZ9Yfy/KvH25LJiQVwfhfWhQvo4N4Q=; b=Cp8pXWWtMw0A4S84EJc4Ugutwf WN7u8VdpbIs9P/9+oE/lh0g5hXw+4Vf2ZW6lqQWAmuDceZa19R41q2TPqxl91fd8UXsq9dsxz3xI6 o0Hty1ZkKixwVPRZIPLWRpy754MSIYc0fDcvIv1vStgsoBHvh8su/hMLr4C4azwVnVZGfkeIivaTZ ceLwYu0EMHXJ+VKU3FCHATPHvGBygzC1sntIvWtc8lIeU0S0lNfCwUeoGt18JJQ6nUTYM28x4lqKD 8O8xb19IPZnPvIz6aobaRSBKULJBsbK+AEN0wvY5yRgRCY0gCTErONS7GoKKwdlzVImDd82VT5lYq Tx1LFR+Q==; Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dwx2S-0005FI-IT for 25351@debbugs.gnu.org; Tue, 26 Sep 2017 23:05:08 +0200 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront12.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1dwx1b-0000dt-5O for 25351@debbugs.gnu.org; Tue, 26 Sep 2017 23:04:15 +0200 From: Gemini Lasswell References: Date: Tue, 26 Sep 2017 14:04:13 -0700 In-Reply-To: (Gemini Lasswell's message of "Tue, 03 Jan 2017 19:06:17 -0800") Message-ID: <877ewlb29e.fsf@runbox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain Here is a patch which fixes this bug by making a copy of the result of the first evaluation of a form to compare with the results of subsequent evaluations. This patch is based on the two patches I sent yesterday to bug#25316. Because Testcover may encounter circular structures in the code it instruments, I wrote a modified version of copy-tree which can handle circular structures. It's possibly generally useful enough to belong in subr.el alongside copy-tree instead of being an internal Testcover function, but I will submit that idea as a separate wishlist item. There isn't currently a version of `equal' which works for circular structures, so Testcover's handling of them is not fully implemented, but it now avoids stopping the code under coverage with an error message. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Stop-Testcover-from-producing-spurious-1value-errors.patch >From 6545b936c2f458f6dbe437e6dec6acc4277d33fd Mon Sep 17 00:00:00 2001 From: Gemini Lasswell Date: Tue, 26 Sep 2017 08:14:23 -0700 Subject: [PATCH] Stop Testcover from producing spurious 1value errors (bug#25351) Fix bug#25351 by copying results of form evaluations for later comparison. * lisp/emacs-lisp/testcover.el (testcover-after): Copy the result of a form's first evaluation and compare subsequent evaluations to the copy. Improve the error message used when a form's value changes. (testcover--copy-object, testcover--copy-object1): New functions. * test/lisp/emacs-lisp/testcover-resources/testcases.el (by-value-vs-by-reference-bug-25351): Remove expected failure tag. (circular-lists-bug-24402): Add another circular list case. --- lisp/emacs-lisp/testcover.el | 95 ++++++++++++++++------ .../emacs-lisp/testcover-resources/testcases.el | 15 +++- 2 files changed, 81 insertions(+), 29 deletions(-) diff --git a/lisp/emacs-lisp/testcover.el b/lisp/emacs-lisp/testcover.el index d9c0d085e5..b9eca67427 100644 --- a/lisp/emacs-lisp/testcover.el +++ b/lisp/emacs-lisp/testcover.el @@ -49,11 +49,10 @@ ;; function being called is capable of returning in other cases. ;; Problems: -;; * To detect different values, we store the form's result in a vector and -;; compare the next result using `equal'. We don't copy the form's -;; result, so if caller alters it (`setcar', etc.) we'll think the next -;; call has the same value! Also, equal thinks two strings are the same -;; if they differ only in properties. +;; * `equal', which is used to compare the results of repeatedly executing +;; a form, has a couple of shortcomings. It considers strings to be the same +;; if they only differ in properties, and it raises an error when asked to +;; compare circular lists. ;; * Because we have only a "1value" class and no "always nil" class, we have ;; to treat as potentially 1-valued any `and' whose last term is 1-valued, ;; in case the last term is always nil. Example: @@ -259,26 +258,25 @@ testcover-after AFTER-INDEX is the form's index into the code-coverage vector. Return VALUE." (let ((old-result (aref testcover-vector after-index))) - (cond - ((eq 'unknown old-result) - (aset testcover-vector after-index value)) - ((eq 'maybe old-result) - (aset testcover-vector after-index 'ok-coverage)) - ((eq '1value old-result) - (aset testcover-vector after-index - (cons old-result value))) - ((and (eq (car-safe old-result) '1value) - (not (condition-case () - (equal (cdr old-result) value) - ;; TODO: Actually check circular lists for equality. - (circular-list t)))) - (error "Value of form marked with `1value' does vary: %s" value)) - ;; Test if a different result. - ((not (condition-case () - (equal value old-result) - ;; TODO: Actually check circular lists for equality. - (circular-list nil))) - (aset testcover-vector after-index 'ok-coverage)))) + (cond + ((eq 'unknown old-result) + (aset testcover-vector after-index (testcover--copy-object value))) + ((eq 'maybe old-result) + (aset testcover-vector after-index 'ok-coverage)) + ((eq '1value old-result) + (aset testcover-vector after-index + (cons old-result (testcover--copy-object value)))) + ((and (eq (car-safe old-result) '1value) + (not (condition-case () + (equal (cdr old-result) value) + (circular-list t)))) + (error "Value of form expected to be constant does vary, from %s to %s" + old-result value)) + ;; Test if a different result. + ((not (condition-case () + (equal value old-result) + (circular-list nil))) + (aset testcover-vector after-index 'ok-coverage)))) value) ;; Add these behaviors to Edebug. @@ -286,6 +284,53 @@ testcover-after (push '(testcover testcover-enter testcover-before testcover-after) edebug-behavior-alist)) +(defun testcover--copy-object (obj) + "Make a copy of OBJ. +If OBJ is a cons cell, copy both its car and its cdr. +Contrast to `copy-tree' which does the same but fails on circular +structures, and `copy-sequence', which copies only along the +cdrs. Copy vectors as well as conses." + (let ((ht (make-hash-table :test 'eq))) + (testcover--copy-object1 obj t ht))) + +(defun testcover--copy-object1 (obj vecp hash-table) + "Make a copy of OBJ, using a HASH-TABLE of objects already copied. +If OBJ is a cons cell, this recursively copies its car and +iteratively copies its cdr. When VECP is non-nil, copy +vectors as well as conses." + (if (and (atom obj) (or (not vecp) (not (vectorp obj)))) + obj + (let ((copy (gethash obj hash-table nil))) + (unless copy + (cond + ((consp obj) + (let* ((rest obj) current) + (setq copy (cons nil nil) + current copy) + (while + (progn + (puthash rest current hash-table) + (setf (car current) + (testcover--copy-object1 (car rest) vecp hash-table)) + (setq rest (cdr rest)) + (cond + ((atom rest) + (setf (cdr current) + (testcover--copy-object1 rest vecp hash-table)) + nil) + ((gethash rest hash-table nil) + (setf (cdr current) (gethash rest hash-table nil)) + nil) + (t (setq current + (setf (cdr current) (cons nil nil))))))))) + (t ; (and vecp (vectorp obj)) is true due to test in if above. + (setq copy (copy-sequence obj)) + (puthash obj copy hash-table) + (dotimes (i (length copy)) + (aset copy i + (testcover--copy-object1 (aref copy i) vecp hash-table)))))) + copy))) + ;;;========================================================================= ;;; Display the coverage data as color splotches on your code. ;;;========================================================================= diff --git a/test/lisp/emacs-lisp/testcover-resources/testcases.el b/test/lisp/emacs-lisp/testcover-resources/testcases.el index 61a457ac36..e4bc3fdb5a 100644 --- a/test/lisp/emacs-lisp/testcover-resources/testcases.el +++ b/test/lisp/emacs-lisp/testcover-resources/testcases.el @@ -357,7 +357,6 @@ testcover-testcase-baz ;; ==== by-value-vs-by-reference-bug-25351 ==== "An object created by a 1value expression may be modified by other code." -:expected-result :failed ;; ==== (defun testcover-testcase-ab () (list 'a 'b)) @@ -483,10 +482,18 @@ testcover-testcase-how-do-i-know-you "Testcover captures and ignores circular list errors." ;; ==== (defun testcover-testcase-cyc1 (a) - (let ((ls (make-list 10 a%%%))) - (nconc ls ls) - ls)) + (let ((ls (make-list 10 a%%%)%%%)) + (nconc ls%%% ls%%%) + ls)) ; The lack of a mark here is due to an ignored circular list error. (testcover-testcase-cyc1 1) (testcover-testcase-cyc1 1) +(defun testcover-testcase-cyc2 (a b) + (let ((ls1 (make-list 10 a%%%)%%%) + (ls2 (make-list 10 b))) + (nconc ls2 ls2) + (nconc ls1%%% ls2) + ls1)) +(testcover-testcase-cyc2 1 2) +(testcover-testcase-cyc2 1 4) ;; testcases.el ends here. -- 2.14.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 26 17:10:28 2017 Received: (at control) by debbugs.gnu.org; 26 Sep 2017 21:10:28 +0000 Received: from localhost ([127.0.0.1]:33708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwx7c-0000wH-BN for submit@debbugs.gnu.org; Tue, 26 Sep 2017 17:10:28 -0400 Received: from aibo.runbox.com ([91.220.196.211]:56840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwx7b-0000w9-7r for control@debbugs.gnu.org; Tue, 26 Sep 2017 17:10:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Subject:From:To:Message-Id:Date; bh=wk1Or2tYSS+lceq0lZVtu79H70CmzCqgTaRvFIujGnA=; b=NhYfqQwirTgZK+GlaV1MjOUI7d yvNOhX/hdptC+cVsGVqft3/sArne54Uhp+ILYNSVNBtl8GiEc5irQUAP0ZY5KB0mBa9GsmfB8uRut gvFo344Qp0JU557B/zsIpzQUDHA+BDrItxbxmADHQRPMXuyAf77VF42ZSQxSAk+lDLKzPLgHESdwX LXRUisJUkWqV2M6TxAQjLgc/llXyGwRqmaQK1vwNkux8UR1H2QSx3m45xKOGD3bMOGDH+LasXJ2Hj BJj6vUgh9qI3v4SudaNpcM6cWshsKyLpe3zW17qx/fsd9fVJOVzyKsyVjxVTAgD9HTW/KIMeVaerJ r+sprf9w==; Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dwx7a-0005ln-6E for control@debbugs.gnu.org; Tue, 26 Sep 2017 23:10:26 +0200 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront12.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1dwx7Z-0005em-Am for control@debbugs.gnu.org; Tue, 26 Sep 2017 23:10:25 +0200 Date: Tue, 26 Sep 2017 14:10:23 -0700 Message-Id: <8760c5b1z4.fsf@runbox.com> To: control@debbugs.gnu.org From: Gemini Lasswell Subject: control message for bug #25351 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) tags 25351 patch From unknown Thu Aug 14 21:51:29 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Gemini Lasswell Subject: bug#25351: closed (Re: bug#25351: Patch for bug#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them) Message-ID: References: <87po9xyz5n.fsf@runbox.com> X-Gnu-PR-Message: they-closed 25351 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 25351@debbugs.gnu.org Date: Sun, 08 Oct 2017 23:54:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1507506842-8526-1" This is a multi-part message in MIME format... ------------=_1507506842-8526-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #25351: 26.0.50; Testcover doesn't work on code that creates simple lists a= nd modifies them which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 25351@debbugs.gnu.org. --=20 25351: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D25351 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1507506842-8526-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 25351-done) by debbugs.gnu.org; 8 Oct 2017 23:53:48 +0000 Received: from localhost ([127.0.0.1]:56880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1LOG-0002D0-MP for submit@debbugs.gnu.org; Sun, 08 Oct 2017 19:53:48 -0400 Received: from aibo.runbox.com ([91.220.196.211]:51570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1LOE-0002Cs-Uu for 25351-done@debbugs.gnu.org; Sun, 08 Oct 2017 19:53:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=5ay431r5BmwVhwxTqE2bScYyUS1tS/v40h3LUI4gsWM=; b=cd3e1/aEwZeqw5ZJ1vtlpub9Nu /rM4uCGVWi+NSDZP6Kne2P/7GpHb6huRq2LIieJ6SRiMthaLBtos0dxLOa4FPad7miFbaydJclcBT VuYsJ7tRX4XTNLwlNVVkrkMMoyqoGeGUhoYgCODYoHxSFeRbLjfy8WS3kBC7N1K2qDlB2Cqc+3hPC Q2JQxNZXcjc61TagJaqwsGl6MD+waKrBRmIzNdug1KMIveRg6IyWMG9umq9Par8wwJJ+MKbGajnNw it/wRpn8AudYoFo5EWt6VtssaQ2hHnzDwg2WRoIjwgzRKkWYvt+OQf7tmps5HHkvKZymiLmA2sGx1 CHwAwGiA==; Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1e1LOE-00061j-6M for 25351-done@debbugs.gnu.org; Mon, 09 Oct 2017 01:53:46 +0200 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront11.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1e1LOA-0003hT-3a for 25351-done@debbugs.gnu.org; Mon, 09 Oct 2017 01:53:42 +0200 From: Gemini Lasswell To: 25351-done@debbugs.gnu.org Subject: Re: bug#25351: Patch for bug#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them References: <877ewlb29e.fsf@runbox.com> Date: Sun, 08 Oct 2017 16:53:40 -0700 In-Reply-To: <877ewlb29e.fsf@runbox.com> (Gemini Lasswell's message of "Tue, 26 Sep 2017 14:04:13 -0700") Message-ID: <87po9xyz5n.fsf@runbox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 25351-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) I've pushed this patch to master. ------------=_1507506842-8526-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 4 Jan 2017 03:06:42 +0000 Received: from localhost ([127.0.0.1]:40695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cObuT-0002If-Pt for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:41 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cObuR-0002IT-Vp for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cObuM-0000c7-1C for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:34 -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]:47614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cObuL-0000c3-UM for submit@debbugs.gnu.org; Tue, 03 Jan 2017 22:06:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cObuI-0006lh-8J for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 22:06:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cObuD-0000Yh-7z for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 22:06:30 -0500 Received: from aibo.runbox.com ([91.220.196.211]:43220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cObuD-0000XU-0g for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2017 22:06:25 -0500 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1cObuA-0006Cx-U4 for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 04:06:22 +0100 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=rainbow.local) by mailfront11.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1cObu7-0001bE-Ob for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2017 04:06:20 +0100 From: Gemini Lasswell To: bug-gnu-emacs@gnu.org Subject: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them Date: Tue, 03 Jan 2017 19:06:17 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) Testcover marks forms which have only returned a single value while under code coverage with a tan splotch to indicate insufficient test coverage, It also identifies forms which will only ever return a single value and suppresses the splotch on those. During the coverage run, it saves a reference to the return value of those single value forms, and the next time the form is evaluated, it uses `equal' to determine if the value has changed, and if it has, Testcover reports an error. The problem with this is that it is a common idiom to create a data structure using an expression that always returns the same thing, and then modify it later. Since Testcover keeps a reference not a copy, it ends up with a reference to a modified object, which fails the comparison with the next return value of the same expression. For example: (defun my-blank-record () (list (list 'name) (list 'age))) (defun my-make-record (name age) (let ((rec (my-blank-record))) (setf (cdr (assq 'name rec)) name) (setf (cdr (assq 'age rec)) age) rec)) (my-make-record "Jack" 10) (my-make-record "Jill" 12) To reproduce this problem, save the above code in a file called bug.el, and then: M-x testcover-start RET bug.el RET The result will be testcover-1value's "Value of form marked with =E2=80=981value=E2=80=99 does vary" error. ------------=_1507506842-8526-1--