]> git.eshelyaron.com Git - emacs.git/commitdiff
Print top time consuming tests if advised
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 19 Mar 2018 11:58:45 +0000 (12:58 +0100)
committerAndrew G Cohen <cohen@andy.bu.edu>
Tue, 11 Dec 2018 06:17:51 +0000 (14:17 +0800)
* lisp/emacs-lisp/ert.el (ert-summarize-tests-batch-and-exit):
New argument HIGH.  Print top-running tests.

* test/Makefile.in (check-doit): Use ${SUMMARIZE_TESTS}.

* test/README: Explain SUMMARIZE_TESTS.

lisp/emacs-lisp/ert.el
test/Makefile.in
test/README

index 09cf28e38badf3ac1b52513da6f4a700abad94e2..32bb367cdb371128f90e92962cac217b55c194cc 100644 (file)
@@ -1491,20 +1491,23 @@ the tests)."
       (kill-emacs 2))))
 
 
-(defun ert-summarize-tests-batch-and-exit ()
+(defun ert-summarize-tests-batch-and-exit (&optional high)
   "Summarize the results of testing.
 Expects to be called in batch mode, with logfiles as command-line arguments.
 The logfiles should have the `ert-run-tests-batch' format.  When finished,
-this exits Emacs, with status as per `ert-run-tests-batch-and-exit'."
+this exits Emacs, with status as per `ert-run-tests-batch-and-exit'.
+
+If HIGH is a natural number, the HIGH long lasting tests are summarized."
   (or noninteractive
       (user-error "This function is only for use in batch mode"))
+  (or (natnump high) (setq high 0))
   ;; Better crash loudly than attempting to recover from undefined
   ;; behavior.
   (setq attempt-stack-overflow-recovery nil
         attempt-orderly-shutdown-on-fatal-signal nil)
   (let ((nlogs (length command-line-args-left))
         (ntests 0) (nrun 0) (nexpected 0) (nunexpected 0) (nskipped 0)
-        nnotrun logfile notests badtests unexpected skipped)
+        nnotrun logfile notests badtests unexpected skipped tests)
     (with-temp-buffer
       (while (setq logfile (pop command-line-args-left))
         (erase-buffer)
@@ -1527,7 +1530,15 @@ Ran \\([0-9]+\\) tests, \\([0-9]+\\) results as expected\
             (when (match-string 5)
               (push logfile skipped)
               (setq nskipped (+ nskipped
-                                (string-to-number (match-string 5)))))))))
+                                (string-to-number (match-string 5)))))
+            (unless (zerop high)
+              (goto-char (point-min))
+              (while (< (point) (point-max))
+                (if (looking-at "^\\s-+\\w+\\s-+[[:digit:]]+/[[:digit:]]+\\s-+\\S-+\\s-+(\\([.[:digit:]]+\\)\\s-+sec)$")
+                    (push (cons (string-to-number (match-string 1))
+                                (match-string 0))
+                          tests))
+                (forward-line)))))))
     (setq nnotrun (- ntests nrun))
     (message "\nSUMMARY OF TEST RESULTS")
     (message "-----------------------")
@@ -1558,6 +1569,12 @@ Ran \\([0-9]+\\) tests, \\([0-9]+\\) results as expected\
     (when unexpected
       (message "%d files contained unexpected results:" (length unexpected))
       (mapc (lambda (l) (message "  %s" l)) unexpected))
+    (unless (or (null tests) (zerop high))
+      (message "\nLONG-RUNNING TESTS")
+      (message "------------------")
+      (setq tests (sort tests (lambda (x y) (> (car x) (car y)))))
+      (when (< high (length tests)) (setcdr (nthcdr (1- high) tests) nil))
+      (message "%s" (mapconcat 'cdr tests "\n")))
     ;; More details on hydra, where the logs are harder to get to.
     (when (and (getenv "EMACS_HYDRA_CI")
                (not (zerop (+ nunexpected nskipped))))
index 20e90c6ce502c54c0b62bda217b04041e0a7aecb..bf1f9f39b710a4300be6796c13df7c604ed43b4a 100644 (file)
@@ -277,7 +277,8 @@ check-maybe: check-no-automated-subdir
 ## summarizing step from running when there is an error.
 check-doit:
        -@${MAKE} -k  ${LOGFILES}
-       @$(emacs) -l ert -f ert-summarize-tests-batch-and-exit ${LOGFILES}
+       @$(emacs) -l ert --eval \
+       "(ert-summarize-tests-batch-and-exit ${SUMMARIZE_TESTS})" ${LOGFILES}
 
 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
 
index 36307e3b6c1e8dbb22355f328d2ee6963ce8084e..b9f6f65c450888222b8949b0b32cf4ddc76ed531 100644 (file)
@@ -65,6 +65,11 @@ compiled version of a test use
 
     make TEST_LOAD_EL=no ...
 
+Some tests might take long time to run.  In order to summarize the
+<nn> tests with the longest duration, call
+
+    make SUMMARIZE_TESTS=<nn> ...
+
 \f
 (Also, see etc/compilation.txt for compilation mode font lock tests.)