[racket] Autotest like tool help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello list.
I am trying to build something like autotest[1] for a racket project I
am working on. It is a tool that I like very much on my rails
development and I am trying to patch together one for racket. I did
manage to get one working, but on my opinion it is ugly as hell and its
output, well, could use a little polishing. So, I am fishing for
suggestions on how to improve this code. I would very much appreciate
any opinions, and I guess this could be transformed into a package for
planet on the future. Here is the code:
;;autotest.rkt
#lang racket
(require racket/path
racket/enter)
(provide start)
;; enter-all-from-root : -> void
;; run all the tests on the system.
(define (enter-all-from-root)
(let* ([test-dirs '("controller" "model" "lib")]
[root-test-files-and-dirs (directory-list)])
(for-each (? (found-dir-or-file)
(when (and (directory-exists? found-dir-or-file)
(not (false? (member (path->string
found-dir-or-file)
test-dirs))))
(enter-all-in-directory found-dir-or-file)))
root-test-files-and-dirs)))
;; enter-all-in-directory : path -> void
;; dynamically loads all modules in the given directory.
(define (enter-all-in-directory a-directory)
(let ([modules (directory-list a-directory)]
[old-current-dir (current-directory)]
[module-white-list (pregexp ".*\\.rkt$")])
(with-handlers ([exn? (? (any-exn)
(displayln (exn-message any-exn))
(current-directory old-current-dir))])
(current-directory a-directory)
(for-each (? (module-path)
(when (and (file-exists? module-path)
(regexp-match? module-white-list
(path->string module-path)))
(eval `(enter! ,(path->string module-path)))))
modules)
(current-directory old-current-dir))))
;; start : ->
(define (start (nap-interval 10))
(enter-all-from-root)
(sleep nap-interval)
(start))
(start)
Thanks for the attention.
[1] http://zentest.rubyforge.org/ZenTest/
- --
Eduardo Bellani
omnia mutantur, nihil interit.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEUEARECAAYFAk05dI0ACgkQSbLl0kCTjGmzIQCcD7SjqJra553GRU1GxTMfLZl+
lfgAl1PunTBD+rB24KZOofwsEGhgiIs=
=UNuE
-----END PGP SIGNATURE-----