emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 2/2] test-ox-html: postamble format
@ 2023-08-09 20:50 Hraban Luyat
  2023-08-09 22:05 ` Hraban Luyat
  0 siblings, 1 reply; 3+ messages in thread
From: Hraban Luyat @ 2023-08-09 20:50 UTC (permalink / raw)
  To: emacs-orgmode

Another test for ox-html, this time for postamble options handling. It's 
quite tricky, apparently.


Hraban




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] test-ox-html: postamble format
  2023-08-09 20:50 [PATCH 2/2] test-ox-html: postamble format Hraban Luyat
@ 2023-08-09 22:05 ` Hraban Luyat
  2023-08-10  9:43   ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Hraban Luyat @ 2023-08-09 22:05 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] test-ox-html: postamble format
  2023-08-09 22:05 ` Hraban Luyat
@ 2023-08-10  9:43   ` Ihor Radchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2023-08-10  9:43 UTC (permalink / raw)
  To: Hraban Luyat; +Cc: emacs-orgmode

Hraban Luyat <hraban@0brg.net> writes:

>> Another test for ox-html, this time for postamble options handling. 
>> It's quite tricky, apparently.

Thanks!
Applied, onto main, after adjusting the commit message.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=39ae2eda5

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-10  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 20:50 [PATCH 2/2] test-ox-html: postamble format Hraban Luyat
2023-08-09 22:05 ` Hraban Luyat
2023-08-10  9:43   ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).