Vim window logic, slimv
This commit is contained in:
parent
babcc9e44b
commit
515847d07e
791 changed files with 51552 additions and 86 deletions
|
|
@ -0,0 +1,42 @@
|
|||
(in-package :cl-user)
|
||||
(defpackage prove.reporter.dot
|
||||
(:use :cl
|
||||
:prove.report
|
||||
:prove.reporter
|
||||
:prove.reporter.list
|
||||
:prove.color))
|
||||
(in-package :prove.reporter.dot)
|
||||
|
||||
(defclass dot-reporter (list-reporter) ())
|
||||
|
||||
(defmethod format-report (stream (reporter dot-reporter) (report comment-report) &rest args)
|
||||
(declare (ignore args))
|
||||
;; Do nothing. This reporter doesn't support 'diag'.
|
||||
)
|
||||
|
||||
(defmethod format-report (stream (reporter dot-reporter) (report test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(when (zerop *indent-level*)
|
||||
(if *enable-colors*
|
||||
(with-color ((cond
|
||||
((failed-report-p report) :red)
|
||||
((skipped-report-p report) :cyan)
|
||||
(T :gray)) :stream stream)
|
||||
(format stream (if (error-report-p report)
|
||||
"x"
|
||||
".")))
|
||||
(write-char (if (failed-report-p report) #\f #\.) stream))))
|
||||
|
||||
(defmethod print-finalize-report :before ((reporter dot-reporter) plan reports stream)
|
||||
(declare (ignore plan reports))
|
||||
(fresh-line stream))
|
||||
|
||||
(defmethod print-finalize-report :after ((reporter dot-reporter) plan reports stream)
|
||||
(let ((failed-reports (remove-if-not #'failed-report-p reports))
|
||||
(list-reporter (make-instance 'list-reporter)))
|
||||
(when failed-reports
|
||||
(format stream "~2&")
|
||||
(map nil
|
||||
(lambda (report)
|
||||
(format-report stream list-reporter report))
|
||||
failed-reports))))
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
(in-package :cl-user)
|
||||
(defpackage prove.reporter.fiveam
|
||||
(:use :cl
|
||||
:prove.report
|
||||
:prove.reporter))
|
||||
(in-package :prove.reporter.fiveam)
|
||||
|
||||
(defclass fiveam-reporter (reporter) ())
|
||||
|
||||
(defmethod format-report (stream (reporter fiveam-reporter) (report comment-report) &rest args)
|
||||
(declare (ignore stream reporter report args))
|
||||
;; Do nothing. This reporter doesn't support 'diag'.
|
||||
)
|
||||
|
||||
(defmethod format-report (stream (reporter fiveam-reporter) (report test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(when (zerop *indent-level*)
|
||||
(write-char (if (failed-report-p report) #\f #\.) stream)))
|
||||
|
||||
(defmethod print-error-report ((reporter fiveam-reporter) (report failed-test-report) stream)
|
||||
(with-slots (description got got-form expected notp report-expected-label print-error-detail) report
|
||||
(cond
|
||||
(print-error-detail
|
||||
(format/indent reporter
|
||||
stream "~& ~:[(no description)~;~:*~A~]:~% ~S~:[~*~; => ~S~]~% is ~:[~;not ~]expected to ~:[be~;~:*~A~]~% ~S~%"
|
||||
description
|
||||
got-form
|
||||
(not (eq got got-form))
|
||||
got
|
||||
notp
|
||||
report-expected-label
|
||||
expected))
|
||||
(T (format/indent reporter stream "~& ~:[(no description)~;~:*~A~]: Failed~%"
|
||||
description)))))
|
||||
|
||||
(defmethod print-error-report ((reporter fiveam-reporter) (report composed-test-report) stream)
|
||||
(with-slots (plan children description) report
|
||||
(format/indent reporter stream "~& ~:[(no description)~;~:*~A~]:~%"
|
||||
description)
|
||||
(let ((*indent-level* (1+ *indent-level*)))
|
||||
(print-finalize-report reporter plan children stream))))
|
||||
|
||||
(defmethod print-error-report ((reporter fiveam-reporter) (report comment-report) stream)
|
||||
(format/indent reporter stream "~& ~A~%"
|
||||
(slot-value report 'description)))
|
||||
|
||||
(defmethod print-finalize-report ((reporter fiveam-reporter) plan reports stream)
|
||||
(let ((failed-count (count-if #'failed-report-p reports))
|
||||
(passed-count (count-if #'passed-report-p reports))
|
||||
(skipped-count (count-if #'skipped-report-p reports))
|
||||
(count (count-if #'test-report-p reports)))
|
||||
(format/indent reporter stream
|
||||
"~& Did ~D checks.~:[~*~; (planned ~D tests)~]~%"
|
||||
count
|
||||
(not (eql plan count))
|
||||
plan)
|
||||
(unless (zerop count)
|
||||
(format/indent reporter
|
||||
stream " Pass: ~D (~3D%)~%" passed-count (round (* (/ passed-count count) 100)))
|
||||
(unless (zerop skipped-count)
|
||||
(format/indent reporter
|
||||
stream " Skip: ~D (~3D%)~%" skipped-count (round (* (/ skipped-count count) 100))))
|
||||
(format/indent reporter
|
||||
stream " Fail: ~D (~3D%)~%" failed-count (round (* (/ failed-count count) 100))))
|
||||
(unless (zerop failed-count)
|
||||
(format/indent reporter
|
||||
stream "~2& Failure Details:~% --------------------------------~%")
|
||||
(loop for report across reports
|
||||
when (failed-report-p report)
|
||||
do (print-error-report reporter report stream)
|
||||
(format/indent reporter stream " --------------------------------~%")))))
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
(in-package :cl-user)
|
||||
(defpackage prove.reporter.list
|
||||
(:use :cl
|
||||
:prove.report
|
||||
:prove.reporter)
|
||||
(:import-from :prove.color
|
||||
:with-color)
|
||||
(:export :list-reporter
|
||||
:report-expected-line))
|
||||
(in-package :prove.reporter.list)
|
||||
|
||||
(defclass list-reporter (reporter) ())
|
||||
|
||||
(defmethod format-report (stream (reporter list-reporter) (report comment-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(with-additional-indent (reporter stream "~& ")
|
||||
(with-color (:white :stream stream)
|
||||
(format/indent reporter stream (slot-value report 'description)))
|
||||
(terpri stream)))
|
||||
|
||||
|
||||
(defun omit-long-value (value)
|
||||
(typecase value
|
||||
(string
|
||||
(if (< 500 (length value))
|
||||
(format nil "\"~A ...\"" (subseq value 0 94))
|
||||
(prin1-to-string value)))
|
||||
(otherwise
|
||||
(let ((value (prin1-to-string value)))
|
||||
(if (< 500 (length value))
|
||||
(format nil "~A ..." (subseq value 0 96))
|
||||
value)))))
|
||||
|
||||
|
||||
(defgeneric report-expected-line (report)
|
||||
(:documentation "Reports about failed or passed test.
|
||||
Should return a string with description of what have happened.")
|
||||
|
||||
(:method ((report normal-test-report))
|
||||
(with-slots (got got-form notp report-expected-label expected) report
|
||||
(escape-tildes
|
||||
(format nil "~A is ~:[~;not ~]expected to ~:[be~;~:*~A~] ~A~:[ (got ~S)~;~*~]"
|
||||
(omit-long-value (or got-form got))
|
||||
notp
|
||||
report-expected-label
|
||||
(omit-long-value expected)
|
||||
(eq got got-form)
|
||||
got)))))
|
||||
|
||||
|
||||
(defun escape-tildes (text)
|
||||
(ppcre:regex-replace-all "~" text "~~"))
|
||||
|
||||
|
||||
(defun possible-report-description (report)
|
||||
(cond
|
||||
((slot-value report 'description)
|
||||
(format nil "~A~:[~; (Skipped)~]"
|
||||
(escape-tildes (slot-value report 'description))
|
||||
(skipped-report-p report)))
|
||||
(T (report-expected-line report))))
|
||||
|
||||
(defun print-duration (stream duration &optional slow-threshold)
|
||||
(let ((color (if slow-threshold
|
||||
(cond
|
||||
((< slow-threshold duration) :red)
|
||||
((< (/ slow-threshold 2) duration) :yellow))
|
||||
:gray)))
|
||||
(when color
|
||||
(with-color (color :stream stream)
|
||||
(format stream "(~Dms)" duration)))))
|
||||
|
||||
(defmethod format-report (stream (reporter list-reporter) (report normal-test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(with-additional-indent (reporter stream "~& ")
|
||||
(with-color (:green :stream stream)
|
||||
(with-additional-indent (reporter stream "✓ ")
|
||||
(let ((description (possible-report-description report))
|
||||
(duration (slot-value report 'duration)))
|
||||
(when description
|
||||
(with-color (:gray :stream stream)
|
||||
(format/indent reporter stream description)))
|
||||
|
||||
(when duration
|
||||
(format stream " ")
|
||||
(print-duration stream duration (slot-value report 'slow-threshold))))
|
||||
(terpri stream)))))
|
||||
|
||||
(defmethod format-report (stream (reporter list-reporter) (report skipped-test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(with-additional-indent (reporter stream "~& ")
|
||||
(with-color (:cyan :stream stream)
|
||||
(with-additional-indent (reporter stream "- ")
|
||||
(let ((description (possible-report-description report)))
|
||||
(when description
|
||||
(format/indent reporter stream description))))
|
||||
(terpri stream))))
|
||||
|
||||
(defmethod format-report (stream (reporter list-reporter) (report failed-test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(with-additional-indent (reporter stream "~& ")
|
||||
(with-color (:red :stream stream)
|
||||
(with-additional-indent (reporter stream "× ")
|
||||
(let ((description (possible-report-description report))
|
||||
(duration (slot-value report 'duration)))
|
||||
(when description
|
||||
(format/indent reporter stream description))
|
||||
(when duration
|
||||
(format stream " ")
|
||||
(print-duration stream duration (slot-value report 'slow-threshold))))
|
||||
(when (slot-value report 'description)
|
||||
(format/indent reporter stream
|
||||
(concatenate 'string "~&" (report-expected-line report)))))
|
||||
(terpri stream))))
|
||||
|
||||
(defmethod format-report (stream (reporter list-reporter) (report error-test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
;; format/indent
|
||||
(with-additional-indent (reporter stream "~& ")
|
||||
(with-color (:red :stream stream)
|
||||
(with-additional-indent (reporter stream "× ")
|
||||
(when (slot-value report 'description)
|
||||
(format/indent reporter stream "~A~%" (slot-value report 'description)))
|
||||
(format/indent reporter stream "Raised an error ~A (expected: ~S)"
|
||||
(slot-value report 'got)
|
||||
(slot-value report 'expected)))))
|
||||
(terpri stream))
|
||||
|
||||
(defmethod format-report (stream (reporter list-reporter) (report composed-test-report) &rest args)
|
||||
(declare (ignore args))
|
||||
;; Do nothing
|
||||
)
|
||||
|
||||
(defmethod print-plan-report ((reporter list-reporter) num stream)
|
||||
(when (numberp num)
|
||||
(format/indent reporter stream "~&1..~A~2%" num)))
|
||||
|
||||
(defmethod print-finalize-report ((reporter list-reporter) plan reports stream)
|
||||
(let ((failed-count (count-if #'failed-report-p reports))
|
||||
(skipped-count (count-if #'skipped-report-p reports))
|
||||
(count (count-if #'test-report-p reports)))
|
||||
(format/indent reporter stream "~2&")
|
||||
(cond
|
||||
((eq plan :unspecified)
|
||||
(with-color (:yellow :stream stream)
|
||||
(format/indent reporter stream
|
||||
"△ Tests were run but no plan was declared.~%")))
|
||||
((and plan
|
||||
(not (= count plan)))
|
||||
(with-color (:yellow :stream stream)
|
||||
(format/indent reporter stream
|
||||
"△ Looks like you planned ~D test~:*~P but ran ~A.~%"
|
||||
plan count))))
|
||||
(if (< 0 failed-count)
|
||||
(with-color (:red :stream stream)
|
||||
(format/indent reporter stream
|
||||
"× ~D of ~D test~:*~P failed"
|
||||
failed-count count))
|
||||
(with-color (:green :stream stream)
|
||||
(format/indent reporter stream
|
||||
"✓ ~D test~:*~P completed" count)))
|
||||
(format stream " ")
|
||||
(print-duration stream
|
||||
(reduce #'+
|
||||
(remove-if-not #'test-report-p reports)
|
||||
:key (lambda (report) (or (slot-value report 'duration) 0))))
|
||||
(terpri stream)
|
||||
(unless (zerop skipped-count)
|
||||
(with-color (:cyan :stream stream)
|
||||
(format/indent reporter stream "● ~D test~:*~P skipped" skipped-count))
|
||||
(terpri stream))))
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
(in-package :cl-user)
|
||||
(defpackage prove.reporter.tap
|
||||
(:use :cl
|
||||
:prove.report
|
||||
:prove.reporter))
|
||||
(in-package :prove.reporter.tap)
|
||||
|
||||
(defclass tap-reporter (reporter)
|
||||
((indent-space :initform 4)))
|
||||
|
||||
(defmethod format-report (stream (reporter tap-reporter) (report comment-report) &rest args)
|
||||
(declare (ignore args))
|
||||
(format/indent reporter stream "~&# ~A~%"
|
||||
(slot-value report 'description)))
|
||||
|
||||
(defmethod format-report (stream (reporter tap-reporter) (report test-report) &key count)
|
||||
(with-slots (description print-error-detail) report
|
||||
(format/indent reporter stream
|
||||
"~&~:[not ~;~]ok~:[~;~:* ~D~]~:[~;~:* - ~A~]~%"
|
||||
(or (passed-report-p report)
|
||||
(skipped-report-p report))
|
||||
count
|
||||
description)
|
||||
(print-error-report reporter report stream)))
|
||||
|
||||
(defmethod format-report (stream (reporter tap-reporter) (report skipped-test-report) &key count)
|
||||
(format/indent reporter stream
|
||||
"~&ok~:[~;~:* ~D~] - skip~:[~;~:* ~A~]~%"
|
||||
count
|
||||
(slot-value report 'description)))
|
||||
|
||||
(defmethod print-error-report ((reporter tap-reporter) (report failed-test-report) stream)
|
||||
(with-slots (got got-form expected notp report-expected-label print-error-detail) report
|
||||
(when print-error-detail
|
||||
(format/indent reporter stream
|
||||
"~&# got: ~S~:[~*~; => ~S~]~%# ~:[~;not ~]expected~:[~;~:* to ~A~]: ~S~%"
|
||||
got-form
|
||||
(not (eq got got-form))
|
||||
got
|
||||
notp
|
||||
report-expected-label
|
||||
expected))))
|
||||
|
||||
(defmethod print-plan-report ((reporter tap-reporter) num stream)
|
||||
(when (numberp num)
|
||||
(format-report stream
|
||||
reporter
|
||||
(make-instance 'report
|
||||
:description (format nil "1..~A" num)))))
|
||||
|
||||
(defmethod print-finalize-report ((reporter tap-reporter) plan reports stream)
|
||||
(let ((failed-count (count-if #'failed-report-p reports))
|
||||
(count (count-if #'test-report-p reports)))
|
||||
(cond
|
||||
((eq plan :unspecified)
|
||||
(format/indent reporter stream
|
||||
"~&# Tests were run but no plan was declared.~%"))
|
||||
((and plan
|
||||
(not (= count plan)))
|
||||
(format/indent reporter stream
|
||||
"~&# Looks like you planned ~D test~:*~P but ran ~A.~%"
|
||||
plan count)))
|
||||
(fresh-line stream)
|
||||
(if (< 0 failed-count)
|
||||
(format/indent reporter stream
|
||||
"# Looks like you failed ~D test~:*~P of ~A run."
|
||||
failed-count count)
|
||||
(format/indent reporter stream "# All ~D test~:*~P passed."
|
||||
count))
|
||||
(terpri stream)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue