diff options
author | Glenn Morris <rgm@gnu.org> | 2017-09-05 20:40:10 -0400 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2017-09-05 20:40:10 -0400 |
commit | 52c9c6b9d80942766ad81183a5d0495bb77eb832 (patch) | |
tree | f032bd08dd675d723bbedfb6d3791c27752bfb13 /lisp/emacs-lisp | |
parent | a2cf4d49f1548b438ce7dd1e99bb2bb8e4e99092 (diff) | |
download | emacs-52c9c6b9d80942766ad81183a5d0495bb77eb832.tar.gz emacs-52c9c6b9d80942766ad81183a5d0495bb77eb832.tar.bz2 emacs-52c9c6b9d80942766ad81183a5d0495bb77eb832.zip |
Allow customizing line length of ert backtraces in batch mode
* lisp/emacs-lisp/ert.el (ert-batch-backtrace-right-margin):
Make it a user option.
(ert-run-tests-batch): Handle ert-batch-backtrace-right-margin nil.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/ert.el | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index c232b08bd1a..323576effe5 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -73,6 +73,11 @@ :prefix "ert-" :group 'lisp) +(defcustom ert-batch-backtrace-right-margin 70 + "Maximum length of lines in ERT backtraces in batch mode. +Use nil for no limit (caution: backtrace lines can be very long)." + :type '(choice (const nil :tag "No truncation") integer)) + (defface ert-test-result-expected '((((class color) (background light)) :background "green1") (((class color) (background dark)) @@ -1329,9 +1334,6 @@ RESULT must be an `ert-test-result-with-condition'." ;;; Running tests in batch mode. -(defvar ert-batch-backtrace-right-margin 70 - "The maximum line length for printing backtraces in `ert-run-tests-batch'.") - ;;;###autoload (defun ert-run-tests-batch (&optional selector) "Run the tests specified by SELECTOR, printing results to the terminal. @@ -1405,15 +1407,20 @@ Returns the stats object." (ert--print-backtrace (ert-test-result-with-condition-backtrace result) nil) - (goto-char (point-min)) - (while (not (eobp)) - (let ((start (point)) - (end (progn (end-of-line) (point)))) - (setq end (min end - (+ start ert-batch-backtrace-right-margin))) - (message "%s" (buffer-substring-no-properties - start end))) - (forward-line 1))) + (if (not ert-batch-backtrace-right-margin) + (message "%s" + (buffer-substring-no-properties (point-min) + (point-max))) + (goto-char (point-min)) + (while (not (eobp)) + (let ((start (point)) + (end (line-end-position))) + (setq end (min end + (+ start + ert-batch-backtrace-right-margin))) + (message "%s" (buffer-substring-no-properties + start end))) + (forward-line 1)))) (with-temp-buffer (ert--insert-infos result) (insert " ") |