From: Hraban Luyat <hraban@0brg.net>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH 2/2] test-ox-html: postamble format
Date: Wed, 09 Aug 2023 22:05:45 +0000 [thread overview]
Message-ID: <e536db3c-4d8d-4fde-9e22-d7ec2b7c8bc4@0brg.net> (raw)
In-Reply-To: <307ba4b5-6147-4907-95c2-ebda20fb037c@0brg.net>
[-- Attachment #1: Type: text/plain, Size: 191 bytes --]
XD forgot the attachment
On 8/9/23 4:50 PM, Hraban Luyat wrote:
> Another test for ox-html, this time for postamble options handling.
> It's quite tricky, apparently.
>
>
> Hraban
>
[-- Attachment #2: 0002-test-ox-html-postamble-format.patch --]
[-- Type: text/plain, Size: 5462 bytes --]
From c054e5d3e9a0813da7c8e269fdfc9ae98c322aa9 Mon Sep 17 00:00:00 2001
From: Hraban Luyat <hraban@0brg.net>
Date: Wed, 9 Aug 2023 16:43:38 -0400
Subject: [PATCH 2/2] test-ox-html: postamble format
---
testing/lisp/test-ox-html.el | 110 +++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/testing/lisp/test-ox-html.el b/testing/lisp/test-ox-html.el
index 76329951b..03c80e5bf 100644
--- a/testing/lisp/test-ox-html.el
+++ b/testing/lisp/test-ox-html.el
@@ -883,5 +883,115 @@ $x$"
(with-current-buffer export-buffer
(libxml-parse-xml-region)))))))
+
+\f
+;;; Postamble Format
+
+(ert-deftest ox-html/postamble-default ()
+ "Test default postamble"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil nil)
+ (with-current-buffer export-buffer
+ (should (= 1 (how-many "Validate")))
+ (should (= 1 (how-many "Created: ")))))))
+
+
+(ert-deftest ox-html/postamble-custom ()
+ "Test custom postamble"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble "Foobar"))
+ (with-current-buffer export-buffer
+ (should (= 0 (how-many "Validate")))
+ (should (= 0 (how-many "Created: ")))
+ (should (= 1 (how-many "Foobar")))))))
+
+(ert-deftest ox-html/postamble-custom-format ()
+ "Test a html-postamble option (not -format) containing a format string"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble "Author=%a"
+ :author "Madame Orange"))
+ (with-current-buffer export-buffer
+ (should (= 0 (how-many "Validate")))
+ (should (= 0 (how-many "Created: ")))
+ (should (= 1 (how-many "Author=Madame Orange")))))))
+
+(ert-deftest ox-html/postamble-none ()
+ "Test no postamble"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble nil))
+ (with-current-buffer export-buffer
+ (should (= 0 (how-many "Validate")))
+ (should (= 0 (how-many "Created: ")))))))
+
+(ert-deftest ox-html/postamble-format-wrong-config ()
+ "Test a html-postamble-format option, with incomplete config.
+
+This option is only picked up when html-postamble is set to
+T. This test leaves it unset, which means it is set to 'auto,
+which will make ox-html skip the html-postamble-format option
+entirely."
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble-format (("en" "Foobar"))))
+ (with-current-buffer export-buffer
+ (should (= 1 (how-many "Validate")))
+ (should (= 1 (how-many "Created: ")))
+ (should (= 0 (how-many "Foobar")))))))
+
+(ert-deftest ox-html/postamble-format-proper-config ()
+ "Test a html-postamble-format option which is just a string"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble-format (("en" "Foobar"))
+ :html-postamble t))
+ (with-current-buffer export-buffer
+ (should (= 0 (how-many "Validate")))
+ (should (= 0 (how-many "Created: ")))
+ (should (= 1 (how-many "Foobar")))))))
+
+(ert-deftest ox-html/postamble-format-conflict ()
+ "Test conflicting postamble and postamble-format configs"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble-format "The format string"
+ :html-postamble "Regular postamble"))
+ (with-current-buffer export-buffer
+ (should (= 0 (how-many "Validate")))
+ (should (= 0 (how-many "Created: ")))
+ (should (= 0 (how-many "The format string")))
+ (should (= 1 (how-many "Regular postamble")))))))
+
+(ert-deftest ox-html/postamble-format-author ()
+ "Test a html-postamble-format option containing the author"
+ (org-test-with-temp-text "Test, hi"
+ (let ((export-buffer "*Test HTML Export*")
+ (org-export-show-temporary-export-buffer nil))
+ (org-export-to-buffer 'html export-buffer
+ nil nil nil nil '(:html-postamble-format (("en" "Author=%a"))
+ :html-postamble t
+ :author "Monsieur Oeuf"))
+ (with-current-buffer export-buffer
+ (should (= 0 (how-many "Validate")))
+ (should (= 0 (how-many "Created: ")))
+ (should (= 1 (how-many "Author=Monsieur Oeuf")))))))
+
(provide 'test-ox-html)
;;; test-ox-html.el ends here
--
2.41.0
next prev parent reply other threads:[~2023-08-09 22:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 20:50 [PATCH 2/2] test-ox-html: postamble format Hraban Luyat
2023-08-09 22:05 ` Hraban Luyat [this message]
2023-08-10 9:43 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e536db3c-4d8d-4fde-9e22-d7ec2b7c8bc4@0brg.net \
--to=hraban@0brg.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.