summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@russet.org.uk>2016-01-27 20:59:50 +0000
committerPhillip Lord <phillip.lord@russet.org.uk>2016-01-27 20:59:50 +0000
commit40ac52e24d20c091deb2cc7595079742facd6842 (patch)
tree544a1eb390e5009842a191aa6ea0e010c64ac15a
parent60902756b0d794b16b9c1c67c4c40a3ac04d1c1b (diff)
downloademacs-feature/parsable-ert-output.tar.gz
Add source information to ERT batch mode.feature/parsable-ert-output
* lisp/emacs-lisp/ert.el (ert-test-location): New function. (ert-run-tests-batch): Add test location.
-rw-r--r--lisp/emacs-lisp/ert.el19
1 files changed, 17 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 7a914da3977..0b6848fa42b 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1330,6 +1330,20 @@ RESULT must be an `ert-test-result-with-condition'."
;;; Running tests in batch mode.
+(defun ert-test-location (test)
+ "Return a string description the source location of TEST."
+ (let* ((loc
+ (find-definition-noselect (ert-test-name test) 'ert-deftest))
+ (buffer
+ (car loc))
+ (point (cdr loc))
+ (file
+ (file-relative-name
+ (buffer-file-name buffer)))
+ (line (with-current-buffer buffer
+ (line-number-at-pos point))))
+ (format "at %s line %s." file line)))
+
(defvar ert-batch-backtrace-right-margin 70
"The maximum line length for printing backtraces in `ert-run-tests-batch'.")
@@ -1435,13 +1449,14 @@ 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 %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)))))))))
+ (ert-test-name test)
+ (ert-test-location test)))))))))
;;;###autoload
(defun ert-run-tests-batch-and-exit (&optional selector)