diff options
| author | Phillip Lord | 2016-01-27 20:59:50 +0000 |
|---|---|---|
| committer | Phillip Lord | 2016-01-27 20:59:50 +0000 |
| commit | 40ac52e24d20c091deb2cc7595079742facd6842 (patch) | |
| tree | 544a1eb390e5009842a191aa6ea0e010c64ac15a | |
| parent | 60902756b0d794b16b9c1c67c4c40a3ac04d1c1b (diff) | |
| download | emacs-feature/parsable-ert-output.tar.gz emacs-feature/parsable-ert-output.zip | |
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.el | 19 |
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'." | |||
| 1330 | 1330 | ||
| 1331 | ;;; Running tests in batch mode. | 1331 | ;;; Running tests in batch mode. |
| 1332 | 1332 | ||
| 1333 | (defun ert-test-location (test) | ||
| 1334 | "Return a string description the source location of TEST." | ||
| 1335 | (let* ((loc | ||
| 1336 | (find-definition-noselect (ert-test-name test) 'ert-deftest)) | ||
| 1337 | (buffer | ||
| 1338 | (car loc)) | ||
| 1339 | (point (cdr loc)) | ||
| 1340 | (file | ||
| 1341 | (file-relative-name | ||
| 1342 | (buffer-file-name buffer))) | ||
| 1343 | (line (with-current-buffer buffer | ||
| 1344 | (line-number-at-pos point)))) | ||
| 1345 | (format "at %s line %s." file line))) | ||
| 1346 | |||
| 1333 | (defvar ert-batch-backtrace-right-margin 70 | 1347 | (defvar ert-batch-backtrace-right-margin 70 |
| 1334 | "The maximum line length for printing backtraces in `ert-run-tests-batch'.") | 1348 | "The maximum line length for printing backtraces in `ert-run-tests-batch'.") |
| 1335 | 1349 | ||
| @@ -1435,13 +1449,14 @@ Returns the stats object." | |||
| 1435 | (let* ((max (prin1-to-string (length (ert--stats-tests stats)))) | 1449 | (let* ((max (prin1-to-string (length (ert--stats-tests stats)))) |
| 1436 | (format-string (concat "%9s %" | 1450 | (format-string (concat "%9s %" |
| 1437 | (prin1-to-string (length max)) | 1451 | (prin1-to-string (length max)) |
| 1438 | "s/" max " %S"))) | 1452 | "s/" max " %S %s"))) |
| 1439 | (message format-string | 1453 | (message format-string |
| 1440 | (ert-string-for-test-result result | 1454 | (ert-string-for-test-result result |
| 1441 | (ert-test-result-expected-p | 1455 | (ert-test-result-expected-p |
| 1442 | test result)) | 1456 | test result)) |
| 1443 | (1+ (ert--stats-test-pos stats test)) | 1457 | (1+ (ert--stats-test-pos stats test)) |
| 1444 | (ert-test-name test))))))))) | 1458 | (ert-test-name test) |
| 1459 | (ert-test-location test))))))))) | ||
| 1445 | 1460 | ||
| 1446 | ;;;###autoload | 1461 | ;;;###autoload |
| 1447 | (defun ert-run-tests-batch-and-exit (&optional selector) | 1462 | (defun ert-run-tests-batch-and-exit (&optional selector) |