Commit 63306108 authored by Ola Nilsson's avatar Ola Nilsson

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.
parent 39d625ce
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment