GNU bug report logs - #24402
25.1.50; testcover-start breaks should-error

Previous Next

Package: emacs;

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

Date: Sat, 10 Sep 2016 02:19:01 UTC

Severity: normal

Tags: confirmed, fixed, patch

Found in versions 25.1.50, 26.0.50

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


Message #8 received at 24402 <at> debbugs.gnu.org (full text, mbox):

From: Gemini Lasswell <gazally <at> runbox.com>
To: 24402 <at> debbugs.gnu.org
Subject: More Information
Date: Mon, 19 Sep 2016 21:27:54 -0700
I’ve done some investigating of why this is happening. testcover-start
transforms:
    (should-error (my-error))
into:
    (should-error (testcover-after 2 (my-error)))

Then the macro expansion of should-error separates the form which it
is passed into a function symbol and list of arguments, and applies
the function to the arguments inside of a condition-case that traps
errors. The problem is that the arguments are evaluated first, outside
of the condition-case, so errors in their evaluation do not get
caught. This problem is not specific to testcover. In this example,
the first test passes and the second fails:

(defun div-by (n)
  (/ 100 n))

(defmacro log-div-by (n)
  `(message "div-by: %d" (div-by ,n)))

(ert-deftest test-div-by ()
  (should-error (div-by 0)))

(ert-deftest test-log-div-by ()
  (should-error (log-div-by 0)))
  







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

Previous Next


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