@@ -374,11 +374,14 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
374
374
(let ((face (cider-test-type-face type)))
375
375
`(:foreground ,(face-attribute face :background ))))
376
376
377
- (defun cider-test-render-summary (buffer summary )
377
+ (defun cider-test-render-summary (buffer summary &optional elapsed-time )
378
378
" Emit into BUFFER the report SUMMARY statistics."
379
379
(with-current-buffer buffer
380
380
(nrepl-dbind-response summary (ns var test pass fail error )
381
- (insert (format " Tested %d namespaces\n " ns))
381
+ (let ((ms (nrepl-dict-get elapsed-time " ms" )))
382
+ (insert (format " Tested %d namespaces%s \n " ns (if ms
383
+ (format " in %s ms " ms)
384
+ " " ))))
382
385
(insert (format " Ran %d assertions, in %d test functions\n " test var))
383
386
(unless (zerop fail)
384
387
(cider-insert (format " %d failures" fail) 'cider-test-failure-face t ))
@@ -391,7 +394,7 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
391
394
(defun cider-test-render-assertion (buffer test )
392
395
" Emit into BUFFER report detail for the TEST assertion."
393
396
(with-current-buffer buffer
394
- (nrepl-dbind-response test (var context type message expected actual diffs error gen-input)
397
+ (nrepl-dbind-response test (var context type message expected actual diffs error gen-input elapsed-time )
395
398
(cl-flet ((insert-label (s)
396
399
(cider-insert (format " %8 s: " s) 'font-lock-comment-face ))
397
400
(insert-align-label (s)
@@ -410,6 +413,9 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
410
413
(bg `(:background , cider-test-items-background-color :extend t )))
411
414
(cider-insert (capitalize type) type-face nil " in " )
412
415
(cider-insert var 'font-lock-function-name-face t )
416
+ (when elapsed-time
417
+ (when-let ((humanized (nrepl-dict-get elapsed-time " humanized" )))
418
+ (cider-insert humanized)))
413
419
(when context (cider-insert context 'font-lock-doc-face t ))
414
420
(when message (cider-insert message 'font-lock-string-face t ))
415
421
(when expected
@@ -450,16 +456,21 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
450
456
test))
451
457
tests))
452
458
453
- (defun cider-test-render-report (buffer summary results )
459
+ (defun cider-test-render-report (buffer summary results &optional elapsed-time ns-elapsed-time )
454
460
" Emit into BUFFER the report for the SUMMARY, and test RESULTS."
455
461
(with-current-buffer buffer
456
462
(let ((inhibit-read-only t ))
457
463
(cider-test-report-mode)
458
464
(cider-insert " Test Summary" 'bold t )
459
465
(dolist (ns (nrepl-dict-keys results))
460
- (insert (cider-propertize ns 'ns ) " \n " ))
466
+ (insert (cider-propertize ns 'ns )
467
+ (or (let ((ms (nrepl-dict-get (nrepl-dict-get ns-elapsed-time ns)
468
+ " ms" )))
469
+ (format " (%s ms) " ms))
470
+ " " )
471
+ " \n " ))
461
472
(cider-insert " \n " )
462
- (cider-test-render-summary buffer summary)
473
+ (cider-test-render-summary buffer summary elapsed-time )
463
474
(nrepl-dbind-response summary (fail error )
464
475
(unless (zerop (+ fail error ))
465
476
(cider-insert " Results" 'bold t " \n " )
@@ -506,22 +517,26 @@ The optional arg TEST denotes an individual test name."
506
517
'ns )
507
518
(unless (stringp ns) " namespaces" )))))
508
519
509
- (defun cider-test-echo-summary (summary results )
510
- " Echo SUMMARY statistics for a test run returning RESULTS."
520
+ (defun cider-test-echo-summary (summary results &optional elapsed-time )
521
+ " Echo SUMMARY statistics for a test run returning RESULTS in ELAPSED-TIME ."
511
522
(nrepl-dbind-response summary (ns test var fail error )
512
523
(if (nrepl-dict-empty-p results)
513
524
(message (concat (propertize " No assertions (or no tests) were run." 'face 'cider-test-error-face )
514
525
" Did you forget to use `is' in your tests?" ))
526
+ (let* ((ms (nrepl-dict-get elapsed-time " ms" ))
527
+ (ms (if ms
528
+ (propertize (concat " in " (prin1-to-string ms) " ms" ) 'face 'font-lock-comment-face )
529
+ " ." )))
515
530
(message (propertize
516
- " %sRan %d assertions, in %d test functions. %d failures, %d errors. "
531
+ " %sRan %d assertions, in %d test functions. %d failures, %d errors%s "
517
532
'face (cond ((not (zerop error )) 'cider-test-error-face )
518
533
((not (zerop fail)) 'cider-test-failure-face )
519
534
(t 'cider-test-success-face )))
520
535
(concat (if (= 1 ns) ; ns count from summary
521
536
(cider-propertize (car (nrepl-dict-keys results)) 'ns )
522
537
(propertize (format " %d namespaces" ns) 'face 'default ))
523
538
(propertize " : " 'face 'default ))
524
- test var fail error ))))
539
+ test var fail error ms) ))))
525
540
526
541
; ;; Test definition highlighting
527
542
; ;
@@ -685,7 +700,7 @@ running them."
685
700
(cider-nrepl-send-request
686
701
request
687
702
(lambda (response )
688
- (nrepl-dbind-response response (summary results status out err)
703
+ (nrepl-dbind-response response (summary results status out err elapsed-time ns-elapsed-time )
689
704
(cond ((member " namespace-not-found" status)
690
705
(unless silent
691
706
(message " No test namespace: %s " (cider-propertize ns 'ns ))))
@@ -696,22 +711,27 @@ running them."
696
711
(setq cider-test-last-summary summary)
697
712
(setq cider-test-last-results results)
698
713
(cider-test-highlight-problems results)
699
- (cider-test-echo-summary summary results)
714
+ (cider-test-echo-summary summary results elapsed-time )
700
715
(if (or (not (zerop (+ error fail)))
701
716
cider-test-show-report-on-success)
702
717
(cider-test-render-report
703
718
(cider-popup-buffer
704
719
cider-test-report-buffer
705
720
cider-auto-select-test-report-buffer)
706
721
summary
707
- results)
722
+ results
723
+ elapsed-time
724
+ ns-elapsed-time)
708
725
(when (get-buffer cider-test-report-buffer)
709
726
(with-current-buffer cider-test-report-buffer
710
727
(let ((inhibit-read-only t ))
711
728
(erase-buffer )))
712
729
(cider-test-render-report
713
730
cider-test-report-buffer
714
- summary results))))))))
731
+ summary
732
+ results
733
+ elapsed-time
734
+ ns-elapsed-time))))))))
715
735
conn))))))
716
736
717
737
(defun cider-test-rerun-failed-tests ()
0 commit comments