aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pogonyshev2017-10-28 13:46:36 +0300
committerEli Zaretskii2017-10-28 13:46:36 +0300
commit6da65bde8c31a1c47070fcde1ff6a3676a51d20d (patch)
treebd36c3bfae85dd37eede693624c85be6fe403f02
parentcb185dfd0c227dda14de25d450d0d684e91cafb3 (diff)
downloademacs-6da65bde8c31a1c47070fcde1ff6a3676a51d20d.tar.gz
emacs-6da65bde8c31a1c47070fcde1ff6a3676a51d20d.zip
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.
-rw-r--r--doc/misc/ert.texi14
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/emacs-lisp/ert.el33
3 files changed, 39 insertions, 14 deletions
diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi
index 4a2c29dcb9f..2a17a211665 100644
--- a/doc/misc/ert.texi
+++ b/doc/misc/ert.texi
@@ -292,6 +292,20 @@ summary as shown below:
292emacs -batch -l ert -f ert-summarize-tests-batch-and-exit output.log 292emacs -batch -l ert -f ert-summarize-tests-batch-and-exit output.log
293@end example 293@end example
294 294
295@vindex ert-quiet
296By default, ERT in batch mode is quite verbose, printing a line with
297result after each test. This gives you progress information: how many
298tests have been executed and how many there are. However, in some
299cases this much output may be undesirable. In this case, set
300@code{ert-quiet} variable to a non-nil value:
301
302@example
303emacs -batch -l ert -l my-tests.el \
304 --eval "(let ((ert-quiet t)) (ert-run-tests-batch-and-exit))"
305@end example
306
307In quiet mode ERT prints only unexpected results and summary.
308
295If ERT is not part of your Emacs distribution, you may need to use 309If ERT is not part of your Emacs distribution, you may need to use
296@code{-L /path/to/ert/} so that Emacs can find it. You may need 310@code{-L /path/to/ert/} so that Emacs can find it. You may need
297additional @code{-L} flags to ensure that @code{my-tests.el} and all the 311additional @code{-L} flags to ensure that @code{my-tests.el} and all the
diff --git a/etc/NEWS b/etc/NEWS
index ec52460f776..9ae36bdb032 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -84,6 +84,12 @@ by default.
84 84
85** Gamegrid 85** Gamegrid
86 86
87** ERT
88
89+++
90*** New variable 'ert-quiet' allows to make ERT output in batch mode
91less verbose by removing non-essential information.
92
87--- 93---
88*** Gamegrid now determines its default glyph size based on display 94*** Gamegrid now determines its default glyph size based on display
89dimensions, instead of always using 16 pixels. As a result, Tetris, 95dimensions, 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 3a3979e81f0..1d69af80639 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'."
1333 1333
1334;;; Running tests in batch mode. 1334;;; Running tests in batch mode.
1335 1335
1336(defvar ert-quiet nil
1337 "Non-nil makes ERT only print important information in batch mode.")
1338
1336;;;###autoload 1339;;;###autoload
1337(defun ert-run-tests-batch (&optional selector) 1340(defun ert-run-tests-batch (&optional selector)
1338 "Run the tests specified by SELECTOR, printing results to the terminal. 1341 "Run the tests specified by SELECTOR, printing results to the terminal.
@@ -1349,10 +1352,11 @@ Returns the stats object."
1349 (lambda (event-type &rest event-args) 1352 (lambda (event-type &rest event-args)
1350 (cl-ecase event-type 1353 (cl-ecase event-type
1351 (run-started 1354 (run-started
1352 (cl-destructuring-bind (stats) event-args 1355 (unless ert-quiet
1353 (message "Running %s tests (%s)" 1356 (cl-destructuring-bind (stats) event-args
1354 (length (ert--stats-tests stats)) 1357 (message "Running %s tests (%s)"
1355 (ert--format-time-iso8601 (ert--stats-start-time stats))))) 1358 (length (ert--stats-tests stats))
1359 (ert--format-time-iso8601 (ert--stats-start-time stats))))))
1356 (run-ended 1360 (run-ended
1357 (cl-destructuring-bind (stats abortedp) event-args 1361 (cl-destructuring-bind (stats abortedp) event-args
1358 (let ((unexpected (ert-stats-completed-unexpected stats)) 1362 (let ((unexpected (ert-stats-completed-unexpected stats))
@@ -1438,16 +1442,17 @@ Returns the stats object."
1438 (ert-test-name test))) 1442 (ert-test-name test)))
1439 (ert-test-quit 1443 (ert-test-quit
1440 (message "Quit during %S" (ert-test-name test))))) 1444 (message "Quit during %S" (ert-test-name test)))))
1441 (let* ((max (prin1-to-string (length (ert--stats-tests stats)))) 1445 (unless ert-quiet
1442 (format-string (concat "%9s %" 1446 (let* ((max (prin1-to-string (length (ert--stats-tests stats))))
1443 (prin1-to-string (length max)) 1447 (format-string (concat "%9s %"
1444 "s/" max " %S"))) 1448 (prin1-to-string (length max))
1445 (message format-string 1449 "s/" max " %S")))
1446 (ert-string-for-test-result result 1450 (message format-string
1447 (ert-test-result-expected-p 1451 (ert-string-for-test-result result
1448 test result)) 1452 (ert-test-result-expected-p
1449 (1+ (ert--stats-test-pos stats test)) 1453 test result))
1450 (ert-test-name test))))))) 1454 (1+ (ert--stats-test-pos stats test))
1455 (ert-test-name test))))))))
1451 nil)) 1456 nil))
1452 1457
1453;;;###autoload 1458;;;###autoload