[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: |
Thu, 4 Apr 2013 21:49:23 -0300 |
Using the command `geiser-racket-test' it's possible to run the tests
in a `test' submodule defined inside the current buffer.
A new buffer, using the Geiser Racket Test Mode (a mode derived from
Compilation Mode), will be open.
As `raco test ...' always returns 0, a wrapper racket program is used
to check if there was any output to stderr. Any output to stderr is
interpret as a failure in some check and the wrapper racket program
returns 1, after letting all the checks run.
---
I've added a new rule to the regexp alist so now it also captures
errors that can occur when something other than a check goes wrong.
The location given in this kind of error is not always of much help,
but it's better than nothing and it's already there anyway.
I also changed the procedure used when calling `raco' so it safely
discards any output to stdout as right now we are only interested in
stderr. There is a recent change to master where stdout outputs the
number of checks that passed and failed. We could take advantage of
this information in the future.
elisp/geiser-racket.el | 31 +++++++++++++++++++++++++++++++
scheme/racket/geiser/test.rkt | 19 +++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100644 scheme/racket/geiser/test.rkt
diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el
index 41262f9..9afbf16 100644
--- a/elisp/geiser-racket.el
+++ b/elisp/geiser-racket.el
@@ -216,6 +216,37 @@ using start-geiser, a procedure in the geiser/server
module."
t)
+;;; Test module
+(defconst geiser-racket-test-regexp-alist
+ (list (list (concat "^location: *(#<path:\\(.*\\)> "
+ "\\([0-9]*\\) \\([0-9]*\\) "
+ "\\([0-9]*\\) \\([0-9]*\\))$")
+ 1 2 3)
+ (list " *\\(.*\\):\\([0-9]*\\):\\([0-9]*\\):" 1 2 3))
+ "Regexp used to match rackunit hits.")
+
+(define-compilation-mode geiser-racket-test-mode "Geiser Racket Test"
+ "Compilation mode for Geiser Racket Test"
+ (set (make-local-variable 'compilation-error-regexp-alist)
+ geiser-racket-test-regexp-alist))
+
+(defun geiser-racket--test-module (filename)
+ "Test a file module with a `test' submodule"
+ (compilation-start
+ (mapconcat
+ #'shell-quote-argument
+ (list (geiser-racket--binary)
+ (expand-file-name "racket/geiser/test.rkt" geiser-scheme-dir)
+ filename)
+ " ")
+ 'geiser-racket-test-mode))
+
+(defun geiser-racket-test ()
+ "Runs 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
diff --git a/scheme/racket/geiser/test.rkt b/scheme/racket/geiser/test.rkt
new file mode 100644
index 0000000..be74d1c
--- /dev/null
+++ b/scheme/racket/geiser/test.rkt
@@ -0,0 +1,19 @@
+#lang racket/base
+
+(require racket/cmdline
+ racket/port
+ racket/system
+ racket/match)
+
+(module+ main
+ (define filename (command-line #:args (filename) filename))
+ (define status 0)
+ (match-let (((list _ _ _ stderr subproc)
+ (process*/ports (open-output-nowhere) #f #f
+ (find-executable-path "raco")
+ "test" filename)))
+ (unless (eof-object? (peek-byte stderr))
+ (copy-port stderr (current-error-port))
+ (set! status 1))
+ (subproc 'wait)
+ (exit status)))
--
1.7.9.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Geiser-users] [PATCH] Add test functionality for Racket and rackunit,
Diogo F. S. Ramos <=