[Top][All Lists]

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

[Geiser-users] [PATCH] Add test functionality for Racket and rackunit

From: Diogo F. S. Ramos
Subject: [Geiser-users] [PATCH] Add test functionality for Racket and rackunit
Date: Tue, 19 Mar 2013 14:51:00 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Using the command `geiser-racket-test' it's possible to run the tests
listed in a `test' submodule defined inside the current buffer.

A new buffer, using the Compilation Mode, will be open and it's
possible to navigate through the errors using the usual keys.
This is just the first interaction of this feature and it's still very
raw, although I argue that it's already useful, but I wanted to show it
to you.

There are some clear next steps, like calling the `raco' command
asynchronously or adding some information about the end result of
running the tests, although this might be harder as `raco test ...'
returns 0 regardless and as in v5.3.3, it always print "testing ...".

Also, I'm not sure how to properly integrate these functions inside

 elisp/geiser-racket.el |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el
index d9d59d1..c71fc94 100644
--- a/elisp/geiser-racket.el
+++ b/elisp/geiser-racket.el
@@ -216,6 +216,40 @@ using start-geiser, a procedure in the geiser/server 
+;;; Test module
+(defun geiser-racket--test-install ()
+  "Install the `rackunit' symbol to compilation alists"
+  (add-to-list 'compilation-error-regexp-alist
+               'rackunit
+               t)
+  (add-to-list 'compilation-error-regexp-alist-alist
+               (list 'rackunit
+                     (concat "^location: *(#<path:\\(.*\\)> "
+                             "\\([0-9]*\\) \\([0-9]*\\) "
+                             "\\([0-9]*\\) \\([0-9]*\\))$")
+                     1 2 3)
+               t (lambda (e el)
+                   (eq (car e) (car el))))
+  t)
+(defun geiser-racket--test-module (filename)
+  "Test a file module using `raco'"
+  (let ((bname "*rackunit*"))
+    (when (get-buffer bname)
+      (kill-buffer bname))
+    (call-process "raco" nil bname t "test" filename)
+    (with-current-buffer bname
+      (compilation-mode "Test"))
+    (switch-to-buffer-other-window bname)))
+(defun geiser-racket-test ()
+  "Runs rackunit tests defined inside a `test' submodule in the current buffer"
+  (interactive)
+  (geiser-racket--test-module (buffer-file-name)))
 ;;; Error display
 (defconst geiser-racket--file-rxs

reply via email to

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