[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup ef7b730 063/340: Various improvements of the bat
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup ef7b730 063/340: Various improvements of the batch reporter. |
Date: |
Thu, 16 Dec 2021 14:59:05 -0500 (EST) |
branch: elpa/buttercup
commit ef7b730c0c6b0f45716bf473f90a1530aa587ec0
Author: Jorgen Schaefer <contact@jorgenschaefer.de>
Commit: Jorgen Schaefer <contact@jorgenschaefer.de>
Various improvements of the batch reporter.
---
buttercup-test.el | 2 +-
buttercup.el | 62 ++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/buttercup-test.el b/buttercup-test.el
index 9d8bd4d..ec5068e 100644
--- a/buttercup-test.el
+++ b/buttercup-test.el
@@ -565,7 +565,7 @@
(expect 'buttercup--print
:to-have-been-called-with
- "%s%s\n"
+ "%s%s"
" "
"spec"))
diff --git a/buttercup.el b/buttercup.el
index e82950e..ce23743 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -632,7 +632,8 @@ current directory."
(defun buttercup-run ()
(if buttercup-suites
- (progn
+ (let ((print-escape-newlines t)
+ (print-escape-nonascii t))
(funcall buttercup-reporter 'buttercup-started buttercup-suites)
(mapc #'buttercup--run-suite buttercup-suites)
(funcall buttercup-reporter 'buttercup-done buttercup-suites))
@@ -710,9 +711,16 @@ suite-done -- A suite has finished. The argument is the
spec.
buttercup-done -- All suites have run, the test run is over.")
+(defvar buttercup-reporter-batch--start-time nil
+ "The time the last batch report started.")
+
+(defvar buttercup-reporter-batch--failures nil
+ "List of failed specs of the current batch report.")
+
(defun buttercup-reporter-batch (event arg)
(pcase event
(`buttercup-started
+ (setq buttercup-reporter-batch--start-time (float-time))
(buttercup--print "Running %s specs.\n\n"
(buttercup-suites-total-specs-defined arg)))
@@ -724,38 +732,55 @@ buttercup-done -- All suites have run, the test run is
over.")
(`spec-started
(let ((level (length (buttercup-spec-parents arg))))
- (buttercup--print "%s%s\n"
+ (buttercup--print "%s%s"
(make-string (* 2 level) ?\s)
(buttercup-spec-description arg))))
(`spec-done
(cond
((eq (buttercup-spec-status arg) 'passed)
- t)
+ (buttercup--print "\n"))
((eq (buttercup-spec-status arg) 'failed)
- (let ((description (buttercup-spec-failure-description arg))
- (stack (buttercup-spec-failure-stack arg)))
- (when stack
- (buttercup--print "\nTraceback (most recent call last):\n")
- (dolist (frame stack)
- (buttercup--print " %S\n" (cdr frame))))
- (if (stringp description)
- (buttercup--print "FAILED: %s\n"
- (buttercup-spec-failure-description arg))
- (buttercup--print "%S: %S\n\n" (car err) (cdr err)))
- (buttercup--print "\n")))
+ (buttercup--print " FAILED\n")
+ (setq buttercup-reporter-batch--failures
+ (append buttercup-reporter-batch--failures
+ (list arg))))
(t
- (buttercup--print "??? %S\n" (buttercup-spec-status arg)))))
+ (error "Unknown spec status %s" (buttercup-spec-status arg)))))
(`suite-done
(when (= 0 (length (buttercup-suite-parents arg)))
(buttercup--print "\n")))
(`buttercup-done
- (buttercup--print "Ran %s specs, %s failed.\n"
+ (dolist (failed buttercup-reporter-batch--failures)
+ (let ((description (buttercup-spec-failure-description failed))
+ (stack (buttercup-spec-failure-stack failed)))
+ (buttercup--print "%s\n" (make-string 40 ?=))
+ (buttercup--print "%s\n" (buttercup-spec-full-name failed))
+ (when stack
+ (buttercup--print "\nTraceback (most recent call last):\n")
+ (dolist (frame stack)
+ (let ((line (format " %S" (cdr frame))))
+ (when (> (length line) 79)
+ (setq line (concat (substring line 0 76)
+ "...")))
+ (buttercup--print "%s\n" line))))
+ (cond
+ ((stringp description)
+ (buttercup--print "FAILED: %s\n" description))
+ ((eq (car description) 'error)
+ (buttercup--print "%S: %S\n\n"
+ (car description)
+ (cadr description)))
+ (t
+ (buttercup--print "FAILED: %S\n" description)))
+ (buttercup--print "\n")))
+ (buttercup--print "Ran %s specs, %s failed, in %.1f seconds.\n"
(buttercup-suites-total-specs-defined arg)
(buttercup-suites-total-specs-failed arg)
- )
+ (- (float-time)
+ buttercup-reporter-batch--start-time))
(when (> (buttercup-suites-total-specs-failed arg) 0)
(error "")))
@@ -763,8 +788,7 @@ buttercup-done -- All suites have run, the test run is
over.")
(error "Unknown event %s" event))))
(defun buttercup--print (fmt &rest args)
- (let ((print-escape-newlines t))
- (princ (apply #'format fmt args))))
+ (send-string-to-terminal (apply #'format fmt args)))
;;;;;;;;;;;;;
;;; Utilities
- [nongnu] elpa/buttercup 8c486e6 067/340: Move print settings to the batch reporter where they belong., (continued)
- [nongnu] elpa/buttercup 8c486e6 067/340: Move print settings to the batch reporter where they belong., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0f3eb63 078/340: Show actual function arguments when a spy fails., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 357e73b 085/340: Remove debug message, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 68692d9 113/340: Update Travis configuration instructions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 54696b0 124/340: Merge pull request #78 from Fuco1/feature/buttercup-minor-mode, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 77f0c74 122/340: Fix :to-have-same-items-as (fix #80), ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 20ec520 145/340: Rename functions and arguments for closure manipulation, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5d1f338 146/340: Move let-binding outside loop for efficiency, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7fa79c4 048/340: Expand and improve the package commentary., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4f68f0b 059/340: The buttercup-spec-full-name function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ef7b730 063/340: Various improvements of the batch reporter.,
ELPA Syncer <=
- [nongnu] elpa/buttercup a55a638 064/340: More and better tests for the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c7df9f6 069/340: Add 24.5., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0c5cc32 057/340: The buttercup-suites-total-specs-defined function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ea8effb 095/340: Add the :var argument to describe, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 23472e9 099/340: :to-match: Show correct error messages, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cc52444 107/340: feature/windows-bin-support: support for windows, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3ef90b4 100/340: :to-match: Don't switch t/nil!, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ab2a558 111/340: Add projectile integration info to Readme, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0124cc4 129/340: Signal an error when ":to-throw" is used on a non-function (#97), ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 31e765b 142/340: Do not suppress errors while loading test files, ELPA Syncer, 2021/12/16