From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jorgen Schaefer Newsgroups: gmane.emacs.devel Subject: Re: Best practice for mocking functions/prompts/etc. Date: Sun, 9 Nov 2014 09:59:09 +0100 Message-ID: <20141109095909.709d26ff@forcix> References: <20141108193423.4e021283@forcix> <87lhnlmgdd.fsf@ferrier.me.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1415523614 30129 80.91.229.3 (9 Nov 2014 09:00:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Nov 2014 09:00:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Nic Ferrier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 09 10:00:07 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XnOLv-0005X7-M7 for ged-emacs-devel@m.gmane.org; Sun, 09 Nov 2014 10:00:07 +0100 Original-Received: from localhost ([::1]:38099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnOLv-00057D-CY for ged-emacs-devel@m.gmane.org; Sun, 09 Nov 2014 04:00:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnOLd-000570-Kg for emacs-devel@gnu.org; Sun, 09 Nov 2014 03:59:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnOLW-0004to-Uz for emacs-devel@gnu.org; Sun, 09 Nov 2014 03:59:49 -0500 Original-Received: from loki.jorgenschaefer.de ([87.230.15.51]:46749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnOLW-0004tV-Os for emacs-devel@gnu.org; Sun, 09 Nov 2014 03:59:42 -0500 Original-Received: by loki.jorgenschaefer.de (Postfix, from userid 998) id 44AC4202F78; Sun, 9 Nov 2014 09:59:11 +0100 (CET) Original-Received: from forcix (port-4080.pppoe.wtnet.de [84.46.15.255]) by loki.jorgenschaefer.de (Postfix) with ESMTPSA id C9BC4202F75; Sun, 9 Nov 2014 09:59:10 +0100 (CET) In-Reply-To: <87lhnlmgdd.fsf@ferrier.me.uk> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; i586-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 87.230.15.51 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:176615 Archived-At: On Sat, 08 Nov 2014 23:17:50 +0000 Nic Ferrier wrote: > Jorgen Schaefer writes: > > > Is there a better way? Especially one that makes it easier to check > > if the function was called at all and with what arguments, as > > opposed to carrying around 1-2 extra variables per mocked function? > > I don't see any reason to test all those things for every interactive > function. I think interactive working (or not) should be tested once, > by some tests around interactive. You don't have to test that. I am not. I am testing whether a function with some complicated logic will ask the user for something when certain conditions are true (and then does the right thing with what it got back from the user). > In this example, you should just mock read-file-name. Which you're > doing. > > Using cl-letf, cl-labels, cl-flet or noflet would all be ok I think. > > There are elisp mocking libs. But with lisp you don't really need > them. Yep. I know how I would do this in my own package, and I know how I can do this with Emacs "on-board" libraries. The latter feels rather cumbersome to me, so I figured I'd ask if there are recommended ways / best practices for packages that are meant to go into the Emacs repository that I am missing. :-) Regards, Jorgen