From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#24402: should-error doesn't catch all errors Date: Wed, 05 Jul 2017 22:43:09 +0900 Message-ID: <874lur0zki.fsf@calancha-pc> References: <3654D8E9-D3CB-402B-922F-B132C1871E9F@runbox.com> <596E65D2-E780-43A1-A75B-603B61B6F9F4@runbox.com> <87zickhoco.fsf_-_@lylat> <877eznda7v.fsf@lylat> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1499262263 8227 195.159.176.226 (5 Jul 2017 13:44:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Jul 2017 13:44:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: Gemini Lasswell , 24402@debbugs.gnu.org To: Alex Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 05 15:44:19 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSkbK-0001pH-BW for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 15:44:18 +0200 Original-Received: from localhost ([::1]:46287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSkbP-0003Oh-Hs for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 09:44:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSkbC-0003Lj-Lh for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 09:44:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSkb4-0006uB-Ub for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 09:44:10 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSkb4-0006u1-QE for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 09:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dSkb4-000747-2t for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 09:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jul 2017 13:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24402 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed patch Original-Received: via spool by 24402-submit@debbugs.gnu.org id=B24402.149926220427105 (code B ref 24402); Wed, 05 Jul 2017 13:44:02 +0000 Original-Received: (at 24402) by debbugs.gnu.org; 5 Jul 2017 13:43:24 +0000 Original-Received: from localhost ([127.0.0.1]:53099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSkaS-000737-1x for submit@debbugs.gnu.org; Wed, 05 Jul 2017 09:43:24 -0400 Original-Received: from mail-pf0-f179.google.com ([209.85.192.179]:36318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSkaP-00072q-7y for 24402@debbugs.gnu.org; Wed, 05 Jul 2017 09:43:21 -0400 Original-Received: by mail-pf0-f179.google.com with SMTP id q86so129980688pfl.3 for <24402@debbugs.gnu.org>; Wed, 05 Jul 2017 06:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=7wCmx+8jdrcaMdP4PatqdkAWyDYf732r9UcRQfcHWQI=; b=t+68t7nDy+xJDNp76uMngha5NJd6lE7HvvxQaITXfMl917nF8RdR+TThWjaAkJMtJm LiUKIH+Wl3XaPj/eSQmSl0XM14W11lbI49Tn9L7lMuvPKJjGHoeZAj5C0J1mzl1T8O23 1MWZR56kfFj45tjm8HcGwatxWpOiVOF62YjZRyOYmiMIg7NkKi+bmh0/2oGir55LvOzE bQigUZU0/IQF3xhtvcQ4HIRDLTi9TTOTOHLkEfHcMBOJ09dV17ob7kyAGtsR3ccScuOw /hBfmo4pSOunLDIPOYtPrq9Yc+e5EgeXcBSEqcpkMIXmQYqrKG3HqUiQY6ZAnqEbgVAh BuxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=7wCmx+8jdrcaMdP4PatqdkAWyDYf732r9UcRQfcHWQI=; b=MM4vbJFkXHcIqHaHqxc389uBD8CDYQFMNs7fX0XVJAKC0zZM6F06t8PGGj76/CWq/C CmudMwcgCcXcqDYO9kEzEEQ6DwmkUWO2LEqgaBo2znpIBm5vk/uv3w5xXYgkfKVWGh9T 425XpE2L8FV/UGSLcGgOohB5jFisunknDoShpl8CGv91SgqKg3WPd+bOwAugDtZS2UmA BG4LteBuyVegmRv0gM2HbAmN3CSwLQIsMB+QT9UU8XH+KZs7PG904G2/tBKClpZlr2Zc 2ngbTUscHmURuDKTG0kUdqsuAMDRL3SgaZYZkVSkZv1ayiMk7nQ4FSnDO54e8KZLSrBz ir0A== X-Gm-Message-State: AIVw112xSIZGvpIHsHSsRRtzTiONmRaPzl4IFCP2/BqtE9GHsT+rKYTv ZgMUxWRGcS5XNFze X-Received: by 10.98.107.133 with SMTP id g127mr20315000pfc.202.1499262195063; Wed, 05 Jul 2017 06:43:15 -0700 (PDT) Original-Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222]) by smtp.gmail.com with ESMTPSA id s87sm34126171pfa.86.2017.07.05.06.43.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jul 2017 06:43:14 -0700 (PDT) In-Reply-To: <877eznda7v.fsf@lylat> (Alex's message of "Tue, 04 Jul 2017 18:00:04 -0600") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134205 Archived-At: Alex writes: > I ran "make check" and found only one test that the above diff breaks: > ert-test-test-result-expected-p. > > I can't seem to figure out why it doesn't work. The test fails because > of these two: > > (let ((test (make-ert-test :body (lambda () (ert-fail "failed"))))) > (should-not (ert-test-result-expected-p test (ert-run-test test)))) > (let ((test (make-ert-test :body (lambda () (ert-fail "failed")) > :expected-result-type ':failed))) > (should (ert-test-result-expected-p test (ert-run-test test)))) > > I tried to re-throw the ert-test-failed signal and still the above two > forms raise error an error. Hi! I just arrived from teletransportation from Bug#27559. Very fast! (and cheap!). Thank you for looking on this. I think you go in the right direction to fix this problem. * I have updated your patch and all the test suite pass (even your proposed tests in Bug#27559 without requiring "(eval '....)"). * Bear in mind that I am far to be an expert on `ert.el', and i am already in my second beer, so please double check that the patch have sense. --8<-----------------------------cut here---------------start------------->8--- commit a07f99f062f3da3418060ef30e1a00030fa0b947 Author: Tino Calancha Date: Wed Jul 5 22:11:46 2017 +0900 Tweak Alex's 2nd patch diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index eb2b2e3e11..2d131cf99e 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -276,13 +276,15 @@ ert--special-operator-p (defun ert--expand-should-1 (whole form inner-expander) "Helper function for the `should' macro and its variants." (let ((form - (macroexpand form (append (bound-and-true-p - byte-compile-macro-environment) - (cond - ((boundp 'macroexpand-all-environment) - macroexpand-all-environment) - ((boundp 'cl-macro-environment) - cl-macro-environment)))))) + (condition-case err + (macroexpand-all form (append (bound-and-true-p + byte-compile-macro-environment) + (cond + ((boundp 'macroexpand-all-environment) + macroexpand-all-environment) + ((boundp 'cl-macro-environment) + cl-macro-environment)))) + (error `(signal ',(car err) ',(cdr err)))))) (cond ((or (atom form) (ert--special-operator-p (car form))) (let ((value (cl-gensym "value-"))) @@ -303,8 +305,14 @@ ert--expand-should-1 (args (cl-gensym "args-")) (value (cl-gensym "value-")) (default-value (cl-gensym "ert-form-evaluation-aborted-"))) - `(let ((,fn (function ,fn-name)) - (,args (list ,@arg-forms))) + `(let* ((,fn (function ,fn-name)) + (,args (condition-case err + (list ,@arg-forms) + (error (if (or (eq (car err) 'ert-test-failed) + (eq (car err) 'ert-test-skipped)) + (list ,@arg-forms) + (setq ,fn #'signal) + (list (car err) (cdr err))))))) (let ((,value ',default-value)) ,(funcall inner-expander `(setq ,value (apply ,fn ,args)) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-07-05 Repository revision: 5d62247323f53f3ae9c7d9f51e951635887b2fb6