Skip to content

Commit

Permalink
Fix test breakage in test-markdown-subtree/move-up.
Browse files Browse the repository at this point in the history
The test is broken prior to Emacs 24.5 due to Emacs bug #19102:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19102
emacs-mirror/emacs@b3910f

While this isn't a bug in the latest version of Emacs 24, it does impact
the version of Emacs 24 in e.g. the most recent long-term-support
distribution of Ubuntu (14.04; the emacs package for that provides Emacs
24.3).

Stephen Berman notes in the bug report (message jrblevin#14):

> The error occurs when the sexp `(= (char-after) ?\n)' in
> outline-move-subtree-down is evaluated at eob. This can happen either
> when calling outline-move-subtree-down on either of the last two
> subtrees, or when calling outline-move-subtree-up on the last subtree.

Failed to find an easy way to work around that in
markdown-mode-move-subtree-up, so this does not change that function.
Instead, it adjusts the test to avoid triggering that outline-mode bug.
It also changes the assertion about the test-markdown-subtree/move-up
to assert the contents of the error message instead of asserting that
the type of the error is 'user-error. That's because prior to the change
that fixed this bug in Emacs 24.5, the type of that error message was
simply 'error.
  • Loading branch information
sfreilich committed Aug 11, 2015
1 parent d76d286 commit ae89ff6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1468,12 +1468,25 @@ the opening bracket of [^2], and then subsequent functions would kill [^2])."

(ert-deftest test-markdown-subtree/move-up ()
"Test `markdown-move-subtree-up'."
(markdown-test-string "# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n# 2 #\n"
;; Note that prior to Emacs 24.5, this does not work for the last subtree in
;; the buffer due to Emacs bug #19102:
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19102
;; https://github.com/emacs-mirror/emacs/commit/b3910f
;; That also corrects the type of the "Cannot move pase superior level" error
;; from 'error to 'user-error.
(markdown-test-string "# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n# 2 #\n# Extra\n"
(re-search-forward "^# 2")
(markdown-move-subtree-up)
(should (string-equal (buffer-string) "# 2 #\n# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n"))
;; Second attempt should fail, leaving buffer unchanged
(should-error (markdown-move-subtree-up) :type 'user-error)))
(should (string-equal (buffer-string) "# 2 #\n# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n# Extra\n"))
;; Second attempt should fail, leaving buffer unchanged.
;; (This way of asserting the contents of the error
;; message is a bit convoluted and more fragile than
;; ideal. But prior to Emacs 24.5, the type of this
;; error is just 'error, and a bare "should-error" is
;; really overly broad.)
(should (string-equal
"Cannot move past superior level"
(second (should-error (markdown-move-subtree-up)))))))

(ert-deftest test-markdown-subtree/move-down ()
"Test `markdown-move-subtree-down'."
Expand Down

0 comments on commit ae89ff6

Please sign in to comment.