Gunit64 – Dev Log
I practice Test Driven Development almost systematically when I write code. So executing tests and reading their results are more than repetitive tasks.
Repetition could lead to automation... Here I present the first features of a tool that should make my life easier. I call it Gunit64!
This article is valid for the following versions:
– guile-gunit64:0.0.1-0.094c17a
– geiser-gunit64:0.0.1-0.7a87357
Introductory tutorial
Given the following SRFI-64 test suite.
The key binding C-c r t
will execute these tests and display the result.
The key binding C-c r f
will only execute tests that failed during the last execution.
The key binding C-c r .
will execute the test at point (the cursor must be somewhere on the string representing the test name).
The key binding C-c r r
will re-execute the tests from the last execution.
Quick explanation
The geiser-gunit
minor mode key bindings will call Emacs Lisp functions which will :
– save all buffers
– compile the current buffer
– evaluate an s-exp in the REPL
This s-exp is one of the procedures exported by the Guile modile gunit64
.
Troubleshooting
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Unbound variable: run-root-tests
You're missing (use-modules (gunit64))
.
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong type to apply: ""
Your tests are not correctly passed to the *test-root*
parameter. Make sure you respect the following model:
(*test-root*
(lambda ()
;;; your tests here))
Installation
- Install guile-gunit64
- Install geiser-gunit64
- Enable
geiser-gunit64-mode
whengeiser-mode
is enabled (via a hook in your Emacs configuration). - Configure Geiser so that the
*Geiser Debug*
buffer processes ANSI colors(setq geiser-debug-treat-ansi-colors 'colors)
. - Configure Geiser not to jump to
*Geiser Debug*
buffer on compile-time error(setq geiser-debug-jump-to-debug nil)
.
For steps 1 and 2, I created the Guix definitions for these 2 packages. You can find them in my personal channel.
Limitations
Gunit64 only handles simple test suites (test-assert
, test-equal
and test-error
). As soon as test-group
is introduced, things get messy. I haven't yet seen how it behaves with user-defined test-runner
(I guess, not very well).
To run your tests from the command line, you have to execute the following command or like :
guile -L . -c "(use-modules (gunit64)) (load \"your-test-file.scm\") (run-root-tests)"
Thank you very much for reading this article! Hope you learned something!
Don't hesitate to give me your opinion, suggest an idea for improvement, report an error, or ask a question ! I would be so glad to discuss about the topic covered here with you ! You can reach me here.
Don't miss out on the next ones ! You can subscribe via RSS or via e-mail just right here !
And more importantly, share this blog and tell your friends why they should read this post!