aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorF. Jason Park2024-08-09 16:49:28 -0700
committerF. Jason Park2024-08-25 09:01:02 -0700
commit0a500193087efc96aa3791dc4c2084ef5f6c3c06 (patch)
treee851fc49ef0819d19ee4992608d90f9af66142af /test
parent713069dd7a87cff8388c25f1bc2c2c1b5217b1ca (diff)
downloademacs-0a500193087efc96aa3791dc4c2084ef5f6c3c06.tar.gz
emacs-0a500193087efc96aa3791dc4c2084ef5f6c3c06.zip
Indent ERT failure explanations rigidly
This also affects the listing of `should' forms produced by hitting the L key on a test button in an ERT buffer. * lisp/emacs-lisp/ert.el (ert--pp-with-indentation-and-newline): Indent the pretty-printed result to match the caller's current column as a reference indentation. * test/lisp/emacs-lisp/ert-tests.el (ert--pp-with-indentation-and-newline): New test. (Bug#72561)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/ert-tests.el54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el
index 1aff73d66f6..9ca336697a6 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -876,6 +876,60 @@ This macro is used to test if macroexpansion in `should' works."
876 (should (eq (ert--get-explainer 'string-equal) 'ert--explain-string-equal)) 876 (should (eq (ert--get-explainer 'string-equal) 'ert--explain-string-equal))
877 (should (eq (ert--get-explainer 'string=) 'ert--explain-string-equal))) 877 (should (eq (ert--get-explainer 'string=) 'ert--explain-string-equal)))
878 878
879(ert-deftest ert--pp-with-indentation-and-newline ()
880 :tags '(:causes-redisplay)
881 (let ((failing-test (make-ert-test
882 :name 'failing-test
883 :body (lambda ()
884 (should (equal '((:one "1" :three "3" :two "2"))
885 '((:one "1")))))))
886 (want-body "\
887Selector: <failing-test>
888Passed: 0
889Failed: 1 (1 unexpected)
890Skipped: 0
891Total: 1/1
892
893Started at: @@TIMESTAMP@@
894Finished.
895Finished at: @@TIMESTAMP@@
896
897F
898
899F failing-test
900 (ert-test-failed
901 ((should (equal '((:one \"1\" :three \"3\" :two \"2\")) '((:one \"1\"))))
902 :form (equal ((:one \"1\" :three \"3\" :two \"2\")) ((:one \"1\"))) :value
903 nil :explanation
904 (list-elt 0
905 (proper-lists-of-different-length 6 2
906 (:one \"1\" :three \"3\"
907 :two \"2\")
908 (:one \"1\")
909 first-mismatch-at 2))))
910\n\n")
911 (want-msg "Ran 1 tests, 0 results were as expected, 1 unexpected")
912 (buffer-name (generate-new-buffer-name " *ert-test-run-tests*")))
913 (cl-letf* ((ert-debug-on-error nil)
914 (ert--output-buffer-name buffer-name)
915 (messages nil)
916 ((symbol-function 'message)
917 (lambda (format-string &rest args)
918 (push (apply #'format format-string args) messages)))
919 ((symbol-function 'ert--format-time-iso8601)
920 (lambda (_) "@@TIMESTAMP@@")))
921 (save-window-excursion
922 (unwind-protect
923 (let ((fill-column 70))
924 (ert-run-tests-interactively failing-test)
925 (should (equal (list want-msg) messages))
926 (should (equal (string-replace "\t" " "
927 (with-current-buffer buffer-name
928 (buffer-string)))
929 want-body)))
930 (when noninteractive
931 (kill-buffer buffer-name)))))))
932
879(provide 'ert-tests) 933(provide 'ert-tests)
880 934
881;;; ert-tests.el ends here 935;;; ert-tests.el ends here