branch: elpa/buttercup commit bd55e2b9c6a6d557394d6a8e8daf33af541832d1 Author: Ola Nilsson <ola.nils...@gmail.com> Commit: Ola Nilsson <ola.nils...@gmail.com>
Add stacktrace style `omit` Setting the backtrace style to `omit` will disable the entire post-report from the batch-reporter. This means that the names of failing tests will not be repeated. Fixes #190. --- bin/buttercup | 21 +++++++++++---------- bin/buttercup.bat | 21 +++++++++++---------- buttercup.el | 7 +++++-- tests/test-buttercup.el | 8 +++++++- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/bin/buttercup b/bin/buttercup index 601a8e0..2230e84 100755 --- a/bin/buttercup +++ b/bin/buttercup @@ -47,16 +47,17 @@ Buttercup options: --traceback STYLE When printing backtraces for errors that occur during tests, print them in the chosen - STYLE. Available styles are "full", which - shows the full function call for each stack - frame on a single line, "crop", which - truncates each stack frame to 80 characters - (the default), and "pretty", which uses - Emacs' pretty-printing facilities to print - each stack frame, and also annotates each - frame with a lambda or M to indicate whether - it is a normal function call or a - macro/special form. + STYLE. Available styles are + "full", which shows the full function call for + each stack frame on a single line, + "crop", which truncates each stack frame to 80 + characters (the default), + "pretty", which uses Emacs' pretty-printing + facilities to print each stack frame, and also + annotates each frame with a lambda or M to + indicate whether it is a normal function call + or a macro/special form and + "omit", which omits the backtraces alltogether. --stale-file-error Fail the test run if stale .elc files are loaded. EOF diff --git a/bin/buttercup.bat b/bin/buttercup.bat index edff81d..108c910 100644 --- a/bin/buttercup.bat +++ b/bin/buttercup.bat @@ -51,16 +51,17 @@ echo --no-color, -c Do not colorize test output. echo. echo --traceback STYLE When printing backtraces for errors that occur echo during tests, print them in the chosen -echo STYLE. Available styles are "full", which -echo shows the full function call for each stack -echo frame on a single line, "crop", which -echo truncates each stack frame to 80 characters -echo ^(the default^), and "pretty", which uses -echo Emacs' pretty-printing facilities to print -echo each stack frame, and also annotates each -echo frame with a lambda or M to indicate whether -echo it is a normal function call or a -echo macro/special form. +echo STYLE. Available styles are +echo "full", which shows the full function call for +echo each stack frame on a single line, +echo "crop", which truncates each stack frame to 80 +echo characters (the default), +echo "pretty", which uses Emacs' pretty-printing +echo facilities to print each stack frame, and also +echo annotates each frame with a lambda or M to +echo indicate whether it is a normal function call +echo or a macro/special form and +echo "omit", which omits the backtraces alltogether. echo. echo --stale-file-error Fail the test run if stale .elc files are loaded. exit /b diff --git a/buttercup.el b/buttercup.el index e6e4cb7..17264b1 100644 --- a/buttercup.el +++ b/buttercup.el @@ -1761,10 +1761,12 @@ Finally print the elapsed time for SPEC." (buttercup-colorize (concat " " failure) color))) (buttercup--print " (%s)\n" (buttercup-elapsed-time-string spec)))) -(defun buttercup-reporter-batch--print-failed-spec-report (failed-spec color) +(cl-defun buttercup-reporter-batch--print-failed-spec-report (failed-spec color) "Print a failure report for FAILED-SPEC. Colorize parts of the output if COLOR is non-nil." + (when (eq buttercup-stack-frame-style 'omit) + (cl-return-from buttercup-reporter-batch--print-failed-spec-report)) (let ((description (buttercup-spec-failure-description failed-spec)) (stack (buttercup-spec-failure-stack failed-spec)) (full-name (buttercup-spec-full-name failed-spec))) @@ -1967,10 +1969,11 @@ ARGS according to `debugger'." (defun buttercup--format-stack-frame (frame &optional style) "Format stack FRAME according to STYLE. -STYLE can be one of `full', `crop', or `pretty'. +STYLE can be one of `full', `crop', `pretty', or `omit'. If STYLE is nil, use `buttercup-stack-frame-style' or `crop'." (setq style (or style buttercup-stack-frame-style 'crop)) (pcase style + (`omit) ; needed to verify valid styles (`full (format " %S" (cdr frame))) (`crop (let ((line (buttercup--format-stack-frame frame 'full))) diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el index bdca141..1ab60d1 100644 --- a/tests/test-buttercup.el +++ b/tests/test-buttercup.el @@ -1487,7 +1487,13 @@ text properties using `ansi-color-apply'." (*? (seq "\n " (* not-newline))) ; any number of pp lines (* not-newline) ")\n")) ;; frame end "error: (" (* anything) ")\n\n" - string-end)))))) + string-end))))) + (it "`omit' should print nothing" + (with-local-buttercup + :suites test-suites :reporter #'backtrace-reporter + :frame-style 'omit + (buttercup-run :noerror) + (expect (buttercup-output) :to-equal "")))) (it "should signal an error for unknown styles" (let ((buttercup-stack-frame-style 'not-a-valid-style)) (expect (buttercup--format-stack-frame '(t myfun 1 2))