GNU bug report logs - #25351
26.0.50; Testcover doesn't work on code that creates simple lists and modifies them

Previous Next

Package: emacs;

Reported by: Gemini Lasswell <gazally <at> runbox.com>

Date: Wed, 4 Jan 2017 03:07:01 UTC

Severity: normal

Tags: patch

Found in version 26.0.50

Done: Gemini Lasswell <gazally <at> runbox.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Gemini Lasswell <gazally <at> runbox.com>
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)
Date: Sun, 08 Oct 2017 23:54:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and 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 <at> debbugs.gnu.org.

-- 
25351: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25351
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Gemini Lasswell <gazally <at> runbox.com>
To: 25351-done <at> 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
Date: Sun, 08 Oct 2017 16:53:40 -0700
I've pushed this patch to master.

[Message part 3 (message/rfc822, inline)]
From: Gemini Lasswell <gazally <at> runbox.com>
To: bug-gnu-emacs <at> 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
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
‘1value’ does vary" error.



This bug report was last modified 7 years and 228 days ago.

Previous Next


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