From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Trigger action at exit? Date: Wed, 05 Mar 2008 21:27:42 +0000 Message-ID: <87d4q8amk1.fsf@ossau.uklinux.net> References: <68dbb6fe0802291430g42240937u1241348a85021e73@mail.gmail.com> <87ve459gxb.fsf@gnu.org> <68dbb6fe0803031322t1dc981cn97e6c3b53c764aac@mail.gmail.com> <87bq5v5vwp.fsf@gnu.org> <68dbb6fe0803031427k66bb76e4la558b35d0db3c975@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204752489 1586 80.91.229.12 (5 Mar 2008 21:28:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Mar 2008 21:28:09 +0000 (UTC) Cc: =?iso-8859-1?Q?Ludovic_Court=E8s?= , guile-user@gnu.org To: "John Trammell" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Mar 05 22:28:35 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JX1A3-0003Px-Ky for guile-user@m.gmane.org; Wed, 05 Mar 2008 22:28:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JX19W-0002BU-3z for guile-user@m.gmane.org; Wed, 05 Mar 2008 16:27:54 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JX19S-0002BK-Nm for guile-user@gnu.org; Wed, 05 Mar 2008 16:27:50 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JX19R-0002As-Dm for guile-user@gnu.org; Wed, 05 Mar 2008 16:27:50 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JX19R-0002Ap-6I for guile-user@gnu.org; Wed, 05 Mar 2008 16:27:49 -0500 Original-Received: from mail3.uklinux.net ([80.84.72.33]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JX19M-0001wP-JX; Wed, 05 Mar 2008 16:27:44 -0500 Original-Received: from arudy (host86-145-183-175.range86-145.btcentralplus.com [86.145.183.175]) by mail3.uklinux.net (Postfix) with ESMTP id B1EFE1F6744; Wed, 5 Mar 2008 21:27:43 +0000 (GMT) Original-Received: from laruns (laruns [192.168.0.10]) by arudy (Postfix) with ESMTP id E84523800A; Wed, 5 Mar 2008 21:27:42 +0000 (GMT) In-Reply-To: <68dbb6fe0803031427k66bb76e4la558b35d0db3c975@mail.gmail.com> (John Trammell's message of "Mon, 3 Mar 2008 16:27:09 -0600") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6444 Archived-At: "John Trammell" writes: > Perl uses a unit testing framework written around the "Test Anything > Protocol" aka. "TAP" (see www.testanything.org). At its simplest, TAP > consists of a header describing the number of tests to run (the > "plan"), then the results of the tests as they are run. One option is > to tell the test framework you don't know how many tests you'll be > running, and have it display the number at the end of the run ("no > plan"). Here's some working code that generates TAP output: > > (use-modules (test TAP estry)) > (load-from-path "atom_p.scm") > (plan 4) > (ok (atom? 'abc)) > (is (atom? 'abc) #t) > (isnt (atom? '()) #t) > (isnt (atom? '(foo)) #t) Something somewhere must be deciding to load that file. If it's just guile -s you could instead do guile -l -s tap-atexit.scm with tap-atexit.scm containing your end of test code. Note, though, that if there is an error in the test code, this approach gives you no way of handling that error. So you might want to consider writing a wrapper for the load operation, something like this: (define (run-test-file file-name) (catch #t (lambda () (load file-name)) (lambda (key . args) ;; do any appropriate reporting and cleanup here ))) (run-test-file (cadr (command-line))) If that code was in a file called tap-wrapper.scm, the Guile invocation would then be guile -s tap-wrapper.scm And once you have wrapper code like this, you could easily add the dynamic-wind that Ludovis suggested. (Or just put the end of test code after the catch.) > Alternatively, we could go OO if I can hook in a handler to the guile > object destruction process. Is that an option? No, there isn't a "guile object" in this sense. Regards, Neil