|
@@ -334,79 +334,113 @@ Unless set otherwise in PROPERTIES, `:base-directory' is set to
|
|
|
"Test `org-publish-get-project-from-filename' specifications."
|
|
|
;; Check base directory.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist '(("p" :base-directory "/base/"))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.org")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist `(("p" :base-directory ,base))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; Return nil if no appropriate project is found.
|
|
|
(should-not
|
|
|
- (let ((org-publish-project-alist '(("p" :base-directory "/base/"))))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist `(("p" :base-directory ,base))))
|
|
|
(org-publish-get-project-from-filename "/other/file.org")))
|
|
|
;; Return the first project effectively publishing the provided
|
|
|
;; file.
|
|
|
(should
|
|
|
(equal "p2"
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p1" :base-directory "/other/")
|
|
|
- ("p2" :base-directory "/base/"))))
|
|
|
- (car (org-publish-get-project-from-filename "/base/file.org")))))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p1" :base-directory "/other/")
|
|
|
+ ("p2" :base-directory ,base))))
|
|
|
+ (car (org-publish-get-project-from-filename file)))))
|
|
|
;; When :recursive in non-nil, allow files in sub-directories.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :recursive t))))
|
|
|
- (org-publish-get-project-from-filename "/base/sub/file.org")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "sub/c.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :recursive t))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
(should-not
|
|
|
- (let ((org-publish-project-alist '(("p" :base-directory "/base/"))))
|
|
|
- (org-publish-get-project-from-filename "/base/sub/file.org")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "sub/c.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :recursive nil))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; Check :base-extension.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :base-extension "txt"))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.txt")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "file.txt" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :base-extension "txt"))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
(should-not
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :base-extension "org"))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.txt")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "file.txt" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :base-extension "org"))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; When :base-extension has the special value `any', allow any
|
|
|
;; extension, including none.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :base-extension any))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.txt")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "file.txt" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :base-extension any))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :base-extension any))))
|
|
|
- (org-publish-get-project-from-filename "/base/file")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "noextension" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :base-extension any))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; Check :exclude property.
|
|
|
(should-not
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :exclude "file"))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.org")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :exclude "a"))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :exclude "other"))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.org")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :exclude "other"))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; The regexp matches against relative file name, not absolute one.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :exclude "base"))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.org")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :exclude "examples/pub"))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; Check :include property.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :include ("file.txt")))))
|
|
|
- (org-publish-get-project-from-filename "/base/file.txt")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "file.txt" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p" :base-directory ,base :include (,file)))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; :include property has precedence over :exclude one.
|
|
|
(should
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("p" :base-directory "/base/" :include ("f.txt") :exclude "f"))))
|
|
|
- (org-publish-get-project-from-filename "/base/f.txt")))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("p"
|
|
|
+ :base-directory ,base
|
|
|
+ :include (,(file-name-nondirectory file))
|
|
|
+ :exclude "a"))))
|
|
|
+ (org-publish-get-project-from-filename file)))
|
|
|
;; With optional argument, return a meta-project publishing provided
|
|
|
;; file.
|
|
|
(should
|
|
|
(equal "meta"
|
|
|
- (let ((org-publish-project-alist
|
|
|
- '(("meta" :components ("p"))
|
|
|
- ("p" :base-directory "/base/"))))
|
|
|
- (car (org-publish-get-project-from-filename "/base/file.org" t))))))
|
|
|
+ (let* ((base (expand-file-name "examples/pub/" org-test-dir))
|
|
|
+ (file (expand-file-name "a.org" base))
|
|
|
+ (org-publish-project-alist
|
|
|
+ `(("meta" :components ("p"))
|
|
|
+ ("p" :base-directory ,base))))
|
|
|
+ (car (org-publish-get-project-from-filename file t))))))
|
|
|
|
|
|
|
|
|
(provide 'test-ox-publish)
|