help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running ERT tests in a rapid convenient manner


From: Eduardo Ochs
Subject: Re: Running ERT tests in a rapid convenient manner
Date: Wed, 23 Apr 2025 19:36:11 -0300

On Wed, 23 Apr 2025 at 17:49, uzibalqa via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> I have a file with ERT tests,
> (...)
>
> How can I make running the tests easier without having to find a directory?
> Have been scrutinising the idea of having a dedicated buffer with buttons
> to execute the tests with the paths predefined.  Is there a better way that
> is more convenient?


Hi uzibalqa,

here's what I would do in/with eev...

I started learning ERT a few minutes ago, so at this moment I am a
person with a single ERT file that I want to modify and test.

I changed your example to add more comments at the top - the `load'
and the `find-2a' - and it became this:


--snip--snip--
;;; marcadores-ert.el -*- lexical-binding: t; -*-
;;
;; (load (buffer-file-name))
;; (find-2a nil '(find-wottb-call '(ert t) "*ert*"))

(require 'ert)

(defun cadores-ertest-fwlabel (expected label width method align)
  "Check string display width and content."
  (let ((result (cadores-fwlabel label width method align)))
    (should (string= expected result))
    (should (= (string-width result) width))))

(ert-deftest ert-cadores-fwlabel-m1-left-align ()
  "Check that short strings are left aligned and padded with
trailing spaces to reach the desired width."
  (cadores-ertest-fwlabel "abc  " "abc" 5 1 'l)
  (cadores-ertest-fwlabel "a    " "a" 5 1 'l))
--snip--snip--


If I go to its line 3 and I type `M-e' there it runs the
`(load (buffer-file-name))', that I don't need to explain.

If I go to its line 4 and I execute the

  (find-2a nil '(find-wottb-call '(ert t) "*ert*"))

it runs `(ert t)' and displays its output at the window at
the right. That's a hack inside another hack: the

  (find-wottb-call '(ert t) "*ert*")

runs `(ert t)' making it use the current window, and the

  (find-2a nil '(find-wottb-call '(ert t) "*ert*"))

shows "marcadores-ert.el" at the window at the left and the
"*ert*" buffer at the window at the right.

If you like that and decide to port its ideas to make
something that doesn't need eev, please share your code!

  Cheers,
    Eduardo Ochs
    http://anggtwu.net/#eev
    http://anggtwu.net/eev-intros/find-multiwindow-intro.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]