summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOla Nilsson <ola.nilsson@gmail.com>2017-10-13 00:00:04 +0200
committerOla Nilsson <ola.nilsson@gmail.com>2018-08-22 22:02:09 +0200
commit633061080e62feb02c75cce27e39c93b24f6e390 (patch)
tree9fca8a0c458c0a83dc054641ce65773f725aa07e
parent39d625ce53bb1e1b9b03d9c9c70aa81e94fcc66a (diff)
Add more markdown running functions
Add function buttercup-run-markdown-buffer that runs all tests found in the current buffer and buttercup-run-markdown-file that runs all tests in a specified file. These new functions are convenient to run markdown tests interactively.
-rw-r--r--buttercup.el46
1 files changed, 34 insertions, 12 deletions
diff --git a/buttercup.el b/buttercup.el
index c199f16..10c09e0 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1254,18 +1254,26 @@ current directory."
(buttercup-run)))
;;;###autoload
-(defun buttercup-run-markdown ()
- "Run all test suites defined in Markdown files passed as arguments.
-A suite must be defined within a Markdown \"lisp\" code block."
- (let ((lisp-buffer (generate-new-buffer "elisp")))
- (dolist (file command-line-args-left)
- (with-current-buffer (find-file-noselect file)
- (goto-char (point-min))
- (let ((case-fold-search t))
- (while (re-search-forward
- "```\\(?:emacs-\\|e\\)?lisp\n\\(\\(?:.\\|\n\\)*?\\)```"
- nil t)
- (let ((code (match-string 1)))
+(defun buttercup-run-markdown-buffer (&rest markdown-buffers)
+ "Run all test suites defined in MARKDOWN-BUFFERS.
+A suite must be defined within a Markdown \"lisp\" code block.
+If MARKDOWN-BUFFERS is empty (nil), use the current buffer."
+ (interactive)
+ (unless markdown-buffers
+ (setq markdown-buffers (list (current-buffer))))
+ (let ((lisp-buffer (generate-new-buffer "elisp"))
+ (case-fold-search t)
+ code
+ buttercup-suites)
+ (dolist (markdown-buffer markdown-buffers)
+ (with-current-buffer markdown-buffer
+ (save-excursion
+ (save-match-data
+ (goto-char (point-min))
+ (while (re-search-forward
+ "```\\(?:emacs-\\|e\\)?lisp\n\\(\\(?:.\\|\n\\)*?\\)```"
+ nil t)
+ (setq code (match-string 1))
(with-current-buffer lisp-buffer
(insert code)))))))
(with-current-buffer lisp-buffer
@@ -1274,6 +1282,20 @@ A suite must be defined within a Markdown \"lisp\" code block."
(point-max)))
(buttercup-run)))
+;;;###autoload
+(defun buttercup-run-markdown ()
+ "Run all test suites defined in Markdown files passed as arguments.
+A suite must be defined within a Markdown \"lisp\" code block."
+ (apply #'buttercup-run-markdown-buffer (mapcar #'find-file-noselect
+ command-line-args-left)))
+
+;;;###autoload
+(defun buttercup-run-markdown-file (file)
+ "Run all test suites defined in Markdown FILE.
+A suite must be defined within a Markdown \"lisp\" code block."
+ (interactive "fMarkdown file: ")
+ (buttercup-run-markdown-buffer (find-file-noselect file)))
+
(eval-when-compile
;; Defined below in a dedicated section
(defvar buttercup-reporter))