From 83913a2b0becb8429e9cc4e5872a9c7557351d03 Mon Sep 17 00:00:00 2001 From: Yasushi SHOJI Date: Mon, 20 Sep 2021 02:10:26 +0900 Subject: [PATCH 3/3] testing: ox-publish: Add a test case for default trans func We use `org-html-publish-to-html' as the default transformation function. This commit adds a test case to make sure that org-publish produces exact same output when org-html-publish-to-html is given as :publishing-function or without it. Because `org-publish-property' checks the given property with `plist-member', we can't pass nil with :publishing-function; This causes ox-publish to error out with "No publishing function chosen". Thus we are removing :publishing-function from the plist using `org-plist-delete-all'. Signed-off-by: Yasushi SHOJI --- testing/lisp/test-ox-publish.el | 36 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/testing/lisp/test-ox-publish.el b/testing/lisp/test-ox-publish.el index 35031742f..3bfb985ab 100644 --- a/testing/lisp/test-ox-publish.el +++ b/testing/lisp/test-ox-publish.el @@ -22,12 +22,16 @@ ;;; Helper functions -(defun org-test-publish (properties handler) +(defun org-test-publish (properties handler &optional remove-prop) "Publish a project defined by PROPERTIES. Call HANDLER with the publishing directory as its sole argument. Unless set otherwise in PROPERTIES, `:base-directory' is set to \"examples/pub/\" sub-directory from test directory and -`:publishing-function' is set to `org-publish-attachment'." +`:publishing-function' is set to `org-publish-attachment'. +Because `org-publish-property' uses `plist-member' to check the +existance of a property, a property with a value nil is different +from non-existitance. Properties in REMOVE-PROP will be remove +from the final plist." (declare (indent 1)) (let* ((org-publish-use-timestamps-flag nil) (org-publish-cache nil) @@ -35,13 +39,15 @@ Unless set otherwise in PROPERTIES, `:base-directory' is set to (pub-dir (make-temp-file "org-test" t)) (org-publish-timestamp-directory (expand-file-name ".org-timestamps/" pub-dir)) + (props (org-plist-delete-all + (org-combine-plists + `(:base-directory ,base-dir + :publishing-function org-publish-attachment) + properties + `(:publishing-directory ,pub-dir)) + remove-prop)) (project - `("test" ,@(org-combine-plists - `(:base-directory - ,base-dir - :publishing-function org-publish-attachment) - properties - `(:publishing-directory ,pub-dir))))) + `("test" ,@props))) (unwind-protect (progn (org-publish-projects (list project)) @@ -92,7 +98,19 @@ Unless set otherwise in PROPERTIES, `:base-directory' is set to (lambda (dir) (remove ".org-timestamps" (cl-remove-if #'file-directory-p - (directory-files dir)))))))) + (directory-files dir))))))) + + ;; Check the default trasformation function, + ;; org-html-publish-to-html. Because org-test-publish uses + ;; org-publish-attachment by default, we must not just override with + ;; nil but tell it to remove the :publishing-function from the list. + (should + (let ((func (lambda (dir) + (with-temp-buffer + (insert-file-contents (expand-file-name "a.html" dir)) + (buffer-string))))) + (equal (org-test-publish nil func '(:publishing-function)) + (org-test-publish '(:publishing-function org-html-publish-to-html) func))))) ;;; Site-map -- 2.33.0