Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TDD functions for emacs
(global-set-key (kbd "C-c C-r") 'run-mocha)
(defun run-mocha()
"Runs all the tests in the current buffer"
(interactive)
(let* (command result exit-value)
(setq command (concat "mocha -r should " (buffer-name)))
(setq exit-value (shell-command command))
(color-modeline exit-value)))
(defun color-modeline(exit-value)
"Colors the modeline, green success red failure"
(interactive)
(let (test-result-color)
(if (= exit-value 0)
(setq test-result-color "Green")
(setq test-result-color "Red"))
(set-face-background 'modeline test-result-color)
(run-at-time "1 sec" nil 'no-color-modeline)))
(defun no-color-modeline()
"No color for the modeline"
(interactive)
(set-face-background 'modeline nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.