From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.bugs Subject: bug#24940: [PATCH] Add should-call, should-not-call, and their tests Date: Mon, 14 Nov 2016 16:18:22 +0000 Message-ID: <87inrqxcfl.fsf@russet.org.uk> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1479140373 27967 195.159.176.226 (14 Nov 2016 16:19:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 14 Nov 2016 16:19:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: 24940@debbugs.gnu.org To: Gemini Lasswell Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 14 17:19:29 2016 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 1c6JyV-00058O-W8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Nov 2016 17:19:16 +0100 Original-Received: from localhost ([::1]:41143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6JyY-0008EX-Vd for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Nov 2016 11:19:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6JyN-0008CT-Lw for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 11:19:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6JyI-000819-P6 for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 11:19:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6JyI-000814-GQ for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 11:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c6JyI-0005gO-3g for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 11:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: phillip.lord@russet.org.uk (Phillip Lord) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Nov 2016 16:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24940 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24940-submit@debbugs.gnu.org id=B24940.147914031121805 (code B ref 24940); Mon, 14 Nov 2016 16:19:02 +0000 Original-Received: (at 24940) by debbugs.gnu.org; 14 Nov 2016 16:18:31 +0000 Original-Received: from localhost ([127.0.0.1]:57289 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6Jxn-0005fd-Lj for submit@debbugs.gnu.org; Mon, 14 Nov 2016 11:18:31 -0500 Original-Received: from cloud103.planethippo.com ([31.216.48.48]:38757) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6Jxl-0005fL-Ha for 24940@debbugs.gnu.org; Mon, 14 Nov 2016 11:18:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CBrhKISLpK0fyndp07nBmVJofYtZGXhLyrtlXaFiRHQ=; b=nn94Z5K8W71sKOFWn01HKSoFs eoq8HYA7ALk+G8rIGmya1Hu0CmK8hQiLsBVS3mzbQKqc5DsAnX16vSWAdhRnsh2rFcKIzoDuad3OK bpbr/VpgLm+N4P6Xq4cZTWeNs6Hm9ophg5gDfy9EbMPXadRnqdA9/ajg7MhB1jFMPtlP/4n0bzZ0g ny9x7GAXwE2WbqPWiVLT6syI8ZZku2K1dIZo0lRkLbkJikd3Oe3ZPGMdrgH39ycCOCDMUPNPbXB07 1omhyaRV2OuKZz3D0IUyqFmppJiYcsHVTpJF+dqybsbdx0PFzGaKW+OYEpSgSNb9Xq7YpV/WS3KgK zmr8xDyyw==; Original-Received: from janus-nat-128-240-225-37.ncl.ac.uk ([128.240.225.37]:59904 helo=russet.org.uk) by cloud103.planethippo.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1c6Jxf-00232s-3i; Mon, 14 Nov 2016 16:18:23 +0000 In-Reply-To: (Gemini Lasswell's message of "Sun, 13 Nov 2016 14:22:08 -0800") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk 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:125690 Archived-At: That's interesting. I'm probably going to add my own package, assess, to ELPA soon, and then to core, which has some similar functionality. https://github.com/phillord/assess Out of curiosity, would assess have fulfilled your use case also? Gemini Lasswell writes: > In the process of writing tests for kmacro.el, I wrote two macros, > should-call and should-not-call, that create context by temporarily > adding advice to named functions. They allow a test writer to express > expectations of how functions are used, to mock up responses of those > functions to the code under test, and to prevent functions from running > which might modify the global state of Emacs in an undesirable way > during a test. > > I think that these macros would be useful additions to ERT. Here is a > patch containing versions of the macros which are integrated into ERT > and which provide better failure reporting than the ones that I included > with the kmacro-tests.el patch in bug#24939. > > I also rewrote one test from files-tests.el as an example of usage and > included it with the patch. It shows how the macros can help make the > logic of a test clearer by removing the clutter of extra variables used > to keep track of the arguments passed in function calls made by the code > under test. For more examples, see the kmacro-tests.el patch in > bug#24939. > > Let me know if you see ways to make this code better, or if there's any > part of adding functionality to Emacs that I've missed here.