emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 6da65bd: Add 'ert-quiet' variable


From: Eli Zaretskii
Subject: [Emacs-diffs] master 6da65bd: Add 'ert-quiet' variable
Date: Sat, 28 Oct 2017 06:50:38 -0400 (EDT)

branch: master
commit 6da65bde8c31a1c47070fcde1ff6a3676a51d20d
Author: Paul Pogonyshev <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Add 'ert-quiet' variable
    
    * lisp/emacs-lisp/ert.el (ert-quiet): New variable.
    (ert-run-tests-batch): When 'ert-quiet' is non-nil, don't
    print non-important information.  (Bug#29025)
    
    * doc/misc/ert.texi (Running Tests in Batch Mode): Document it.
    
    * etc/NEWS: Mention the new variable.
---
 doc/misc/ert.texi      | 14 ++++++++++++++
 etc/NEWS               |  6 ++++++
 lisp/emacs-lisp/ert.el | 33 +++++++++++++++++++--------------
 3 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi
index 4a2c29d..2a17a21 100644
--- a/doc/misc/ert.texi
+++ b/doc/misc/ert.texi
@@ -292,6 +292,20 @@ summary as shown below:
 emacs -batch -l ert -f ert-summarize-tests-batch-and-exit output.log
 @end example
 
address@hidden ert-quiet
+By default, ERT in batch mode is quite verbose, printing a line with
+result after each test.  This gives you progress information: how many
+tests have been executed and how many there are.  However, in some
+cases this much output may be undesirable.  In this case, set
address@hidden variable to a non-nil value:
+
address@hidden
+emacs -batch -l ert -l my-tests.el \
+      --eval "(let ((ert-quiet t)) (ert-run-tests-batch-and-exit))"
address@hidden example
+
+In quiet mode ERT prints only unexpected results and summary.
+
 If ERT is not part of your Emacs distribution, you may need to use
 @code{-L /path/to/ert/} so that Emacs can find it.  You may need
 additional @code{-L} flags to ensure that @code{my-tests.el} and all the
diff --git a/etc/NEWS b/etc/NEWS
index ec52460..9ae36bd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -84,6 +84,12 @@ by default.
 
 ** Gamegrid
 
+** ERT
+
++++
+*** New variable 'ert-quiet' allows to make ERT output in batch mode
+less verbose by removing non-essential information.
+
 ---
 *** Gamegrid now determines its default glyph size based on display
 dimensions, instead of always using 16 pixels. As a result, Tetris,
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 3a3979e..1d69af8 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1333,6 +1333,9 @@ RESULT must be an `ert-test-result-with-condition'."
 
 ;;; Running tests in batch mode.
 
+(defvar ert-quiet nil
+  "Non-nil makes ERT only print important information in batch mode.")
+
 ;;;###autoload
 (defun ert-run-tests-batch (&optional selector)
   "Run the tests specified by SELECTOR, printing results to the terminal.
@@ -1349,10 +1352,11 @@ Returns the stats object."
    (lambda (event-type &rest event-args)
      (cl-ecase event-type
        (run-started
-        (cl-destructuring-bind (stats) event-args
-          (message "Running %s tests (%s)"
-                   (length (ert--stats-tests stats))
-                   (ert--format-time-iso8601 (ert--stats-start-time stats)))))
+        (unless ert-quiet
+          (cl-destructuring-bind (stats) event-args
+            (message "Running %s tests (%s)"
+                     (length (ert--stats-tests stats))
+                     (ert--format-time-iso8601 (ert--stats-start-time 
stats))))))
        (run-ended
         (cl-destructuring-bind (stats abortedp) event-args
           (let ((unexpected (ert-stats-completed-unexpected stats))
@@ -1438,16 +1442,17 @@ Returns the stats object."
                         (ert-test-name test)))
               (ert-test-quit
                (message "Quit during %S" (ert-test-name test)))))
-          (let* ((max (prin1-to-string (length (ert--stats-tests stats))))
-                 (format-string (concat "%9s  %"
-                                        (prin1-to-string (length max))
-                                        "s/" max "  %S")))
-            (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)))))))
+          (unless ert-quiet
+            (let* ((max (prin1-to-string (length (ert--stats-tests stats))))
+                   (format-string (concat "%9s  %"
+                                          (prin1-to-string (length max))
+                                          "s/" max "  %S")))
+              (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))))))))
    nil))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]