[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/gnus-select e3338f2 078/218: Extend ert to print d
From: |
Andrew G Cohen |
Subject: |
[Emacs-diffs] feature/gnus-select e3338f2 078/218: Extend ert to print duration of single tests |
Date: |
Fri, 14 Dec 2018 03:35:03 -0500 (EST) |
branch: feature/gnus-select
commit e3338f29335e2e2b73478436266ff0944da7b925
Author: Michael Albinus <address@hidden>
Commit: Andrew G Cohen <address@hidden>
Extend ert to print duration of single tests
* lisp/emacs-lisp/ert.el (ert-test-result): New slot ´duration'.
(ert-run-or-rerun-test): Set it.
(ert-batch-print-duration): New defvar.
(ert-run-tests-batch): Print duration if needed.
* test/Makefile.in (TEST_PRINT_TEST_DURATION): New variable.
* test/README: Explain TEST_PRINT_TEST_DURATION.
---
lisp/emacs-lisp/ert.el | 17 +++++++++++++++--
test/Makefile.in | 14 ++++++++++----
test/README | 5 +++++
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index a471085..7d8d0a5 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -676,6 +676,7 @@ and is displayed in front of the value of MESSAGE-FORM."
(cl-defstruct ert-test-result
(messages nil)
(should-forms nil)
+ (duration 0)
)
(cl-defstruct (ert-test-passed (:include ert-test-result)))
(cl-defstruct (ert-test-result-with-condition (:include ert-test-result))
@@ -1230,6 +1231,11 @@ SELECTOR is the selector that was used to select TESTS."
(ert-run-test test)
(setf (aref (ert--stats-test-end-times stats) pos) (current-time))
(let ((result (ert-test-most-recent-result test)))
+ (setf (ert-test-result-duration result)
+ (float-time
+ (time-subtract
+ (aref (ert--stats-test-end-times stats) pos)
+ (aref (ert--stats-test-start-times stats) pos))))
(ert--stats-set-test-and-result stats pos test result)
(funcall listener 'test-ended stats test result))
(setf (ert--stats-current-test stats) nil))))
@@ -1336,6 +1342,9 @@ RESULT must be an `ert-test-result-with-condition'."
(defvar ert-quiet nil
"Non-nil makes ERT only print important information in batch mode.")
+(defvar ert-batch-print-duration nil
+ "Non-nil makes ERT print duration time of single tests in batch mode.")
+
;;;###autoload
(defun ert-run-tests-batch (&optional selector)
"Run the tests specified by SELECTOR, printing results to the terminal.
@@ -1446,13 +1455,17 @@ Returns the stats object."
(let* ((max (prin1-to-string (length (ert--stats-tests stats))))
(format-string (concat "%9s %"
(prin1-to-string (length max))
- "s/" max " %S")))
+ "s/" max " %S"
+ (if ert-batch-print-duration
+ " (%f sec)"))))
(message format-string
(ert-string-for-test-result result
(ert-test-result-expected-p
test result))
(1+ (ert--stats-test-pos stats test))
- (ert-test-name test))))))))
+ (ert-test-name test)
+ (if ert-batch-print-duration
+ (ert-test-result-duration result)))))))))
nil))
;;;###autoload
diff --git a/test/Makefile.in b/test/Makefile.in
index 42d9880..0b6f8c2 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -99,14 +99,20 @@ TEST_LOCALE = C
# If you just want a pass/fail, setting this to no is much faster.
TEST_LOAD_EL ?= yes
+# Additional settings for ert.
+ert_opts =
+
# Maximum length of lines in ert backtraces; nil for no limit.
# (if empty, use the default ert-batch-backtrace-right-margin).
TEST_BACKTRACE_LINE_LENGTH =
-ifeq (${TEST_BACKTRACE_LINE_LENGTH},)
-ert_opts =
-else
-ert_opts = --eval '(setq ert-batch-backtrace-right-margin
${TEST_BACKTRACE_LINE_LENGTH})'
+ifneq (${TEST_BACKTRACE_LINE_LENGTH},)
+ert_opts += --eval '(setq ert-batch-backtrace-right-margin
${TEST_BACKTRACE_LINE_LENGTH})'
+endif
+
+# Whether the tests shall also report their duration.
+ifdef TEST_PRINT_TEST_DURATION
+ert_opts += --eval '(setq ert-batch-print-duration t)'
endif
ifeq (@HAVE_MODULES@, yes)
diff --git a/test/README b/test/README
index 1cd9db3..11a25fb 100644
--- a/test/README
+++ b/test/README
@@ -50,6 +50,11 @@ nicer backtraces. To run the compiled version of a test use
make TEST_LOAD_EL=no ...
+Sometimes, it is ncessary to trace the duration time for single tests.
+This is controlled by the environment variable TEST_PRINT_TEST_DURATION
+
+ make TEST_PRINT_TEST_DURATION=1 ...
+
(Also, see etc/compilation.txt for compilation mode font lock tests.)
- [Emacs-diffs] feature/gnus-select b92cf09 065/218: Stop mentioning options.el in doc, (continued)
- [Emacs-diffs] feature/gnus-select b92cf09 065/218: Stop mentioning options.el in doc, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 2005a72 069/218: Avoid assertion violation under visual-order-cursor-movement, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select b405149 072/218: * src/xdisp.c (Fwindow_text_pixel_size): Fix last change., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select ea586a7 081/218: Fix problems caused by fontconfig-2.13.0, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 3b92c80 068/218: * lisp/subr.el (focus-frame, unfocus-frame): Remove obsolete no-ops., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 64c4ec0 082/218: More hydra.nixos.org logging for unfinished tests, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 066e71d 056/218: More changes in the Emacs manual, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 212e217 064/218: * lisp/loadhist.el (unload-hook-features-list): Remove obsolete alias., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 88a19e4 080/218: * lisp/desktop.el: Make use some "new" functionality, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select d27fdc5 085/218: Fix an error in tramp-archive-test42-auto-load, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select e3338f2 078/218: Extend ert to print duration of single tests,
Andrew G Cohen <=
- [Emacs-diffs] feature/gnus-select 7928693 020/218: Fix 'window-text-pixel-size' when display properties are around, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 850e683 023/218: ; Tiny fix for recent doc change, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 7a082db 022/218: Minor change in the manual, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 6e30330 041/218: Clarify that nil doesn't match itself as a cl-case clause (Bug#30749), Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select eeda1f8 015/218: Update from Gnulib, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select e269430 039/218: Document the "URL" keyword in library headers, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select ecb867a 027/218: Replace uses of the obsolete local-write-file-hooks, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 9be7eb4 034/218: Quieten --without-json compilation of json-tests.el, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 496ccae 036/218: * Makefile.in (check-declare): Also check test/ directory., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select e16a1e7 028/218: Replace the obsolete process-kill-without-query in documentation, Andrew G Cohen, 2018/12/14