Subject: Re: bug#26889: Tests for emacs-clojure-mode

From: [email-masked] (Ludovic Courtès)
Date: Fri, 12 May 2017 23:48:13 +0200

Hi Arun,

Arun Isaac <[email-masked]> skribis:

> From 52c39f301978ec7081f43466aec5211185eb43dd Mon Sep 17 00:00:00 2001
> From: Arun Isaac <[email-masked]>
> Date: Thu, 11 May 2017 23:23:30 +0530
> Subject: [PATCH 1/4] gnu: Add emacs-ansi.
>
> * gnu/packages/emacs.scm (emacs-ansi): New variable.

LGTM.

> From 75b5e7ae59be84680077dca4942eecca275f7c8c Mon Sep 17 00:00:00 2001
> From: Arun Isaac <[email-masked]>
> Date: Thu, 11 May 2017 23:24:43 +0530
> Subject: [PATCH 2/4] gnu: Add emacs-commander.
>
> * gnu/packages/emacs.scm (emacs-commander): New variable.

LGTM.

> From 77491a17bbbaef34d94bd37732a031988796aa66 Mon Sep 17 00:00:00 2001
> From: Arun Isaac <[email-masked]>
> Date: Thu, 11 May 2017 23:25:27 +0530
> Subject: [PATCH 3/4] gnu: Add ert-runner.
>
> * gnu/packages/emacs.scm (ert-runner): New variable.

[...]

> +(define-public ert-runner
> +  (let ((dependencies
> +         `(("emacs-ansi" ,emacs-ansi)
> +           ("emacs-commander" ,emacs-commander)
> +           ("emacs-dash" ,emacs-dash)
> +           ("emacs-f" ,emacs-f)
> +           ("emacs-s" ,emacs-s)
> +           ("emacs-shut-up" ,emacs-shut-up))))

[...]

> +                 (wrap-program (string-append out "/bin/ert-runner")
> +                   (list "EMACSLOADPATH" ":" '=
> +                         (append
> +                          (map (lambda (name version)
> +                                 (string-append
> +                                  (assoc-ref inputs name)
> +                                  "/share/emacs/site-lisp/guix.d/"
> +                                  (substring name 6) "-" version))
> +                               ',(map car dependencies)
> +                               ',(map (compose package-version cadr) dependencies))
> +                          (list ""))))))))))

I’d suggest ‘match’ instead of car/cadr, and ‘string-drop’
instead of ‘substring’.

Also, I think we should avoid relying on the fact that input labels are
equal to the corresponding package name.  For instance, procedures like
‘package-for-guile-2.2’ mechanically rewrite packages and change their
names, but they do not change the labels.

That gives something like

  ,(match dependencies
     (((labels packages) ...)
      `(map (lambda (label package version)
               (string-append (assoc-ref inputs label)
                              "/share/…" (string-drop package 6)
                              "-" version))
            ',labels
            ',(map package-name packages)
            ',(map package-version packages))))

Last thing: this phase should return #t after the call to
‘wrap-program’.

OK with changes along these lines!

> From 8b9bfa1f646d7211514395400adb1abaf4c2369c Mon Sep 17 00:00:00 2001
> From: Arun Isaac <[email-masked]>
> Date: Thu, 11 May 2017 23:28:53 +0530
> Subject: [PATCH 4/4] gnu: emacs-clojure-mode: Enable tests.
>
> * gnu/packages/emacs.scm (emacs-clojure-mode)[arguments]: Add 'check' phase.
> [native-inputs]: Add emacs-dash, emacs-s and ert-runner.

LGTM.

Thank you!

Ludo’.