bug#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them
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.
bug#25351: Patch for bug#25351: 26.0.50; Testcover doesn't work on code that creates simple lists and modifies them
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
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