all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Merten <smerten@oekonux.de>
To: emacs-devel@gnu.org
Cc: Jonathan Yavner <jyavner@member.fsf.org>
Subject: testcover: setf-method and treatment of `defcustom'
Date: Mon, 10 Sep 2012 09:11:42 +0200	[thread overview]
Message-ID: <6900.1347261102@theowa.merten-home.homelinux.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 2697 bytes --]

Hi!

I just found the `testcover' package in Emacs 23.1.1 (the source in
Emacs 24 changed only very slightly). I tried it with my tests for
rst.el and after a lot of investigation got it to work with my `ert'
based test suite.

I had to solve two problems. When I ran my ert tests some of them fail
with

	No setf-method known for testcover-after

I looked into this and found `defsetf' in `cl-macs'. `testcover-after'
is a function which has only some side effect. I think

  (defsetf testcover-after (idx val) (store)
    (list 'progn
	  (list 'testcover-after idx val)
	  (list 'setf val store)))

does the right thing. At least the error messages described above
vanish for me.

AFAICS the only thing which can go wrong with this setf-method seems
to be the double evaluation of `val' - although I don't know whether
this really is evaluated twice in this context. Too much macro...

I still had another error left, however.

	 Value of form marked with `1value' does vary: ...

It took me some time to discover that for some reason `testcover'
treats `defcustom' like `defconst'. This is of course lethal for a
test which changes a customizable variable temporarily - e.g. by `let'
- to test a certain functionality.

For now I defined

  (defun rst-defcustom-testcover ()
    "Remove all customized variables from `testcover-module-constants'.
  This seems to be a bug in `testcover': `defcustom' variables are
  considered constants.  Revert it with this function after each `defcustom'."
    (when (boundp 'testcover-module-constants)
      (setq testcover-module-constants
	    (delq nil
		  (mapcar
		   (lambda (sym)
		     (if (not (plist-member (symbol-plist sym) 'standard-value))
			 sym))
		   testcover-module-constants)))))

and put a call to this function after every `defcustom'. This helps
but IMHO is of selected ugliness.

I'd rather suggest this patch (against Emacs 24 sources):

  --- ../emacs/trunk/lisp/emacs-lisp/testcover.el	2012-04-20 19:50:27.000000000 +0200
  +++ /home/stefan/tmp/testcover.el	2012-09-10 08:58:01.000000000 +0200
  @@ -297,7 +297,7 @@
	  (push (cadr form) testcover-module-1value-functions))
	 (when (eq val 'maybe)
	  (push (cadr form) testcover-module-potentially-1value-functions)))
  -     ((memq fun '(defconst defcustom))
  +     ((eq fun 'defconst)
	 ;;Define this symbol as 1-valued
	 (push (cadr form) testcover-module-constants)
	 (testcover-reinstrument-list (cddr form)))

In addition it would be certainly helpful to integrate the `defsetf'
form above somehow in `testcover'. However, I have no idea how to do
this in a good way.


						Grüße

						Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 307 bytes --]

             reply	other threads:[~2012-09-10  7:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10  7:11 Stefan Merten [this message]
2012-09-11  3:40 ` testcover: setf-method and treatment of `defcustom' Stefan Monnier
2012-09-12 20:38   ` Stefan Merten
2012-09-13 13:09     ` Stefan Monnier
2012-09-13 20:45       ` Stefan Merten
2012-09-16  9:06   ` Stefan Merten
2012-09-18 21:37     ` Stefan Monnier
2012-09-12 19:32 ` Stefan Merten

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6900.1347261102@theowa.merten-home.homelinux.org \
    --to=smerten@oekonux.de \
    --cc=emacs-devel@gnu.org \
    --cc=jyavner@member.fsf.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.