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

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

[nongnu] elpa/buttercup 6330610 176/340: Add more markdown running funct


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 6330610 176/340: Add more markdown running functions
Date: Thu, 16 Dec 2021 14:59:29 -0500 (EST)

branch: elpa/buttercup
commit 633061080e62feb02c75cce27e39c93b24f6e390
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>

    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.
---
 buttercup.el | 46 ++++++++++++++++++++++++++++++++++------------
 1 file 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))



reply via email to

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