Function: ert--stats-set-test-and-result

ert--stats-set-test-and-result is a byte-compiled function defined in ert.el.gz.

Signature

(ert--stats-set-test-and-result STATS POS TEST RESULT)

Documentation

Change STATS by replacing the test at position POS with TEST and RESULT.

Also changes the counters in STATS to match.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/ert.el.gz
(defun ert--stats-set-test-and-result (stats pos test result)
  "Change STATS by replacing the test at position POS with TEST and RESULT.

Also changes the counters in STATS to match."
  (let* ((tests (ert--stats-tests stats))
         (results (ert--stats-test-results stats))
         (old-test (aref tests pos))
         (map (ert--stats-test-map stats)))
    (cl-flet ((update (d)
                (if (ert-test-result-expected-p (aref tests pos)
                                                (aref results pos))
                    (cl-etypecase (aref results pos)
                      (ert-test-passed
                       (incf (ert--stats-passed-expected stats) d))
                      (ert-test-failed
                       (incf (ert--stats-failed-expected stats) d))
		      (ert-test-skipped
                       (incf (ert--stats-skipped stats) d))
                      (null)
                      (ert-test-aborted-with-non-local-exit)
                      (ert-test-quit))
                  (cl-etypecase (aref results pos)
                    (ert-test-passed
                     (incf (ert--stats-passed-unexpected stats) d))
                    (ert-test-failed
                     (incf (ert--stats-failed-unexpected stats) d))
                    (ert-test-skipped
                     (incf (ert--stats-skipped stats) d))
                    (null)
                    (ert-test-aborted-with-non-local-exit)
                    (ert-test-quit)))))
      ;; Adjust counters to remove the result that is currently in stats.
      (update -1)
      ;; Put new test and result into stats.
      (setf (aref tests pos) test
            (aref results pos) result)
      (remhash (ert--stats-test-key old-test) map)
      (setf (gethash (ert--stats-test-key test) map) pos)
      ;; Adjust counters to match new result.
      (update +1)
      nil)))