emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 9a0f304 06/26: New function `test-simple-run': register te


From: Rocky Bernstein
Subject: [elpa] master 9a0f304 06/26: New function `test-simple-run': register test
Date: Thu, 25 May 2017 02:22:13 -0400 (EDT)

branch: master
commit 9a0f304f9141e671e74555b779ea33610b6c3582
Author: rubikitch <address@hidden>
Commit: rubikitch <address@hidden>

    New function `test-simple-run': register test
    
    You can run tests easily by pressing C-x C-z.
---
 test-simple.el | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/test-simple.el b/test-simple.el
index 72cdca0..b9b4ffb 100644
--- a/test-simple.el
+++ b/test-simple.el
@@ -1,4 +1,4 @@
-;;; test-simple.el --- Simple Unit Test Framework for Emacs Lisp
+;;; test-simple.el --- Simple Unit Test Framework for Emacs Lisp -*- 
lexical-binding: t -*-
 ;; Rewritten from Phil Hagelberg's behave.el by rocky
 
 ;; Copyright (C) 2015 Free Software Foundation, Inc
@@ -97,6 +97,26 @@
   )
 (require 'cl)
 
+(defgroup test-simple nil
+  "Simple Unit Test Framework for Emacs Lisp"
+  :group 'lisp)
+
+(defcustom test-simple-runner-interface (if (fboundp 'bpr-spawn)
+                                            'bpr-spawn
+                                          'compile)
+  "Function with one string argument when running tests non-interactively.
+Command line started with `emacs --batch' is passed as the argument.
+
+`bpr-spawn', which is in bpr package, is preferable because of no window popup.
+If bpr is not installed, fall back to `compile'."
+  :type 'function
+  :group 'test-simple)
+
+(defcustom test-simple-runner-key "C-x C-z"
+  "Key to run non-interactive test after defining command line by 
`test-simple-run'."
+  :type 'string
+  :group 'test-simple)
+
 (defvar test-simple-debug-on-error nil
   "If non-nil raise an error on the first failure.")
 
@@ -330,5 +350,20 @@ funnel down to this one, ASSERT-TYPE is an optional type."
   (goto-char (point-max))
   (test-simple-msg (test-simple-summary-line test-info)))
 
+;;;###autoload
+(defun test-simple-run (&rest command-line-formats)
+  "Register command line to run tests non-interactively and bind key to run 
test.
+After calling this function, you can run test by key specified by 
`test-simple-runner-key'.
+
+It is preferable to write at the first line of test files as a comment, e.g,
+;;;; (test-simple-run \"emacs -batch -L %s -l %s\" (file-name-directory 
(locate-library \"test-simple.elc\")) buffer-file-name)
+"
+  (let ((func (lambda ()
+                (interactive)
+                (funcall test-simple-runner-interface
+                         (apply 'format command-line-formats)))))
+    (global-set-key (kbd test-simple-runner-key) func)
+    (funcall func)))
+
 (provide 'test-simple)
 ;;; test-simple.el ends here



reply via email to

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