aboutsummaryrefslogtreecommitdiff
path: root/lisp/seam-test.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/seam-test.el')
-rw-r--r--lisp/seam-test.el36
1 files changed, 12 insertions, 24 deletions
diff --git a/lisp/seam-test.el b/lisp/seam-test.el
index 5d4a562..9ab1b22 100644
--- a/lisp/seam-test.el
+++ b/lisp/seam-test.el
@@ -39,7 +39,7 @@
(defmacro seam-test-environment (&rest body)
(declare (indent 0))
- `(let* ((seam-test-directory (make-temp-file "seam-test" t))
+ `(let* ((seam-test-directory (file-name-as-directory (make-temp-file "seam-test" t)))
(seam-note-directory seam-test-directory)
(default-directory seam-test-directory)
(seam-note-types '("private" "public"))
@@ -66,15 +66,17 @@
(let ,options
(let ,(cl-loop for (name . args) in varlist
collect `(,name (seam-make-note ,@args)))
+ ;; FIXME: It's quite possible for tests to fail in such a way
+ ;; that this does not kill the buffers.
(unwind-protect (progn ,@body)
(mapcar #'kill-buffer (list ,@(mapcar #'car varlist))))))))
-(defun seam-test-remove-testdir (filename)
- (string-remove-prefix (concat seam-test-directory "/") filename))
+(defun seam-test-strip-testdir (filename)
+ (string-remove-prefix seam-test-directory filename))
(defun seam-test-list-files ()
(mapcar
- #'seam-test-remove-testdir
+ #'seam-test-strip-testdir
(directory-files-recursively seam-test-directory "")))
(defun seam-test-add-contents (buffer contents)
@@ -119,9 +121,9 @@
(ert-deftest seam-test-make-note-weird-filename ()
(should
(equal
- '("./Weird file name!" ("private/weird-file-name.org"))
+ '("./Weir'd file name!" ("private/weird-file-name.org"))
(seam-test-with-notes ()
- ((weird "./Weird file name! "))
+ ((weird "./Weir'd file name! "))
(list (buffer-name weird)
(seam-test-list-files))))))
@@ -222,7 +224,7 @@
(seam-test-replace-contents bar "* qux")
(list
(seam-test-links-from-html "html/foo.html")
- (mapcar #'seam-test-remove-testdir (seam-get-links-from-file (buffer-file-name foo)))
+ (mapcar #'seam-test-strip-testdir (seam-get-links-from-file (buffer-file-name foo)))
(seam-test-list-files)))))))
(ert-deftest seam-test-link-update-no-unnecessary-export ()
@@ -297,9 +299,9 @@ the class."
(seam-test-add-contents foo (seam-test-link-to-buffer qux))
(seam-test-add-contents bar (seam-test-link-to-buffer qux))
(list
- (mapcar #'seam-test-remove-testdir (seam-get-links-from-file (buffer-file-name foo)))
- (mapcar #'seam-test-remove-testdir (seam-get-links-to-file (buffer-file-name bar)))
- (mapcar #'seam-test-remove-testdir (seam-get-links-to-file (buffer-file-name qux))))))))
+ (mapcar #'seam-test-strip-testdir (seam-get-links-from-file (buffer-file-name foo)))
+ (mapcar #'seam-test-strip-testdir (seam-get-links-to-file (buffer-file-name bar)))
+ (mapcar #'seam-test-strip-testdir (seam-get-links-to-file (buffer-file-name qux))))))))
(ert-deftest seam-test-delete-note ()
"Test that deleting a note also deletes its HTML and re-exports linking
@@ -358,20 +360,6 @@ backlink."
(insert-file-contents "html/bar.html")
(re-search-forward "<a href=\"/foo.html\">")))))
-(ert-deftest seam-test-backlinks-comment ()
- "Test that a commented-out link does not add a backlink."
- :expected-result :failed
- (should-error
- (identity
- (seam-test-with-notes ((seam-export-template-string "{{backlinks}}"))
- ((foo "foo" "public")
- (bar "bar" "public"))
- (with-current-buffer foo
- (seam-test-add-contents foo (concat "# " (seam-test-link-to-buffer bar))))
- (with-temp-buffer
- (insert-file-contents "html/bar.html")
- (re-search-forward "<a href=\"/foo.html\">"))))))
-
(ert-deftest seam-test-set-type-private ()
"Test that setting a public note to private will delete its HTML file and
update linking HTML files such that they no longer link to it."