[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/parsable-ert-output 40ac52e: Add source informatio
From: |
Phillip Lord |
Subject: |
[Emacs-diffs] feature/parsable-ert-output 40ac52e: Add source information to ERT batch mode. |
Date: |
Wed, 27 Jan 2016 21:01:22 +0000 |
branch: feature/parsable-ert-output
commit 40ac52e24d20c091deb2cc7595079742facd6842
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>
Add source information to ERT batch mode.
* lisp/emacs-lisp/ert.el (ert-test-location): New function.
(ert-run-tests-batch): Add test location.
---
lisp/emacs-lisp/ert.el | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 7a914da..0b6848f 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)