[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c6b3234 07/13: Additional tests and minor cleanup
From: |
Ian Dunn |
Subject: |
[elpa] master c6b3234 07/13: Additional tests and minor cleanup |
Date: |
Sun, 25 Nov 2018 14:09:48 -0500 (EST) |
branch: master
commit c6b32343ad22ce4b83ee1dd6dd68516fa04e02c1
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Additional tests and minor cleanup
* org-edna.el: Added some section headers.
* org-edna-tests.el (org-edna-doc-test/ancestors-cache):
(org-edna-doc-test/descendants-cache):
(org-edna-doc-test/laundry-cache):
(org-edna-doc-test/nightly-cache): Added tests for run-through with cache.
---
org-edna-tests.el | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
org-edna.el | 7 ++-
2 files changed, 174 insertions(+), 4 deletions(-)
diff --git a/org-edna-tests.el b/org-edna-tests.el
index da8e437..5b0b1e0 100644
--- a/org-edna-tests.el
+++ b/org-edna-tests.el
@@ -3,9 +3,6 @@
;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
;; Author: Ian Dunn <address@hidden>
-;; Keywords: convenience, text, org
-;; Version: 1.0
-;; Package-Requires: ((emacs "25.1") (seq "2.19") (org "8.0"))
;; This file is NOT part of GNU Emacs.
@@ -1646,6 +1643,39 @@ This avoids org-id digging into its internal database."
(org-edna-test-mark-todo heading1-pom heading3-pom heading4-pom
heading5-pom))))
(org-edna-test-restore-test-file))))
+(ert-deftest org-edna-doc-test/ancestors-cache ()
+ (let* ((start-heading (org-edna-find-test-heading
"24a0c3bb-7e69-4e9e-bb98-5aba2ff17bb1"))
+ (org-todo-keywords '((sequence "TODO" "|" "DONE")))
+ ;; Only block based on Edna
+ (org-blocker-hook 'org-edna-blocker-function)
+ ;; Enable cache
+ (org-edna-finder-use-cache t))
+ (unwind-protect
+ (org-with-point-at start-heading
+ (save-restriction
+ ;; Only allow operating on the current tree
+ (org-narrow-to-subtree)
+ ;; Show the entire subtree
+ (outline-show-all)
+ (let* ((heading1-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading2-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading3-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading4-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading5-pom (progn (org-next-visible-heading 1)
(point-marker))))
+ ;; Verify that we can't change the TODO state to DONE
+ (should (org-edna-test-check-block heading5-pom "Initial state
of heading 5"))
+ ;; Change the state at 4 to DONE
+ (org-edna-test-change-todo-state heading4-pom "DONE")
+ ;; Verify that ALL ancestors need to be changed
+ (should (org-edna-test-check-block heading5-pom "Heading 5 after
parent changed"))
+ (org-edna-test-mark-done heading1-pom heading3-pom)
+ ;; Only need 1, 3, and 4 to change 5
+ (should (not (org-edna-test-check-block heading5-pom
+ "Heading 5 after all
parents changed")))
+ ;; Change the state back to TODO on all of them
+ (org-edna-test-mark-todo heading1-pom heading3-pom heading4-pom
heading5-pom))))
+ (org-edna-test-restore-test-file))))
+
(ert-deftest org-edna-doc-test/descendants ()
(let* ((start-heading (org-edna-find-test-heading
"cc18dc74-00e8-4081-b46f-e36800041fe7"))
(org-todo-keywords '((sequence "TODO" "|" "DONE")))
@@ -1682,6 +1712,44 @@ This avoids org-id digging into its internal database."
(should (not (org-edna-test-check-block heading1-pom "Heading 1
after changing 5"))))))
(org-edna-test-restore-test-file))))
+(ert-deftest org-edna-doc-test/descendants-cache ()
+ (let* ((start-heading (org-edna-find-test-heading
"cc18dc74-00e8-4081-b46f-e36800041fe7"))
+ (org-todo-keywords '((sequence "TODO" "|" "DONE")))
+ ;; Only block based on Edna
+ (org-blocker-hook 'org-edna-blocker-function)
+ ;; Enable cache
+ (org-edna-finder-use-cache t))
+ (unwind-protect
+ (org-with-point-at start-heading
+ (save-restriction
+ ;; Only allow operating on the current tree
+ (org-narrow-to-subtree)
+ ;; Show the entire subtree
+ (outline-show-all)
+ (let* ((heading1-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading2-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading3-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading4-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading5-pom (progn (org-next-visible-heading 1)
(point-marker))))
+ (should (org-edna-test-check-block heading1-pom "Heading 1
initial state"))
+ ;; Change the state at 2 to DONE
+ (org-edna-test-mark-done heading2-pom)
+ ;; Verify that ALL descendants need to be changed
+ (should (org-edna-test-check-block heading1-pom "Heading 1 after
changing 2"))
+ ;; Try 3
+ (org-edna-test-mark-done heading3-pom)
+ ;; Verify that ALL descendants need to be changed
+ (should (org-edna-test-check-block heading1-pom "Heading 1 after
changing 3"))
+ ;; Try 4
+ (org-edna-test-mark-done heading4-pom)
+ ;; Verify that ALL descendants need to be changed
+ (should (org-edna-test-check-block heading1-pom "Heading 1 after
changing 4"))
+ ;; Try 5
+ (org-edna-test-mark-done heading5-pom)
+ ;; Verify that ALL descendants need to be changed
+ (should (not (org-edna-test-check-block heading1-pom "Heading 1
after changing 5"))))))
+ (org-edna-test-restore-test-file))))
+
(ert-deftest org-edna-doc-test/laundry ()
"Test for the \"laundry\" example in the documentation."
(cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
@@ -1733,6 +1801,62 @@ This avoids org-id digging into its internal database."
;; Change the test file back to its original state.
(org-edna-test-restore-test-file))))))
+(ert-deftest org-edna-doc-test/laundry-cache ()
+ "Test for the \"laundry\" example in the documentation.
+
+This version enables cache, ensuring that the repeated calls to
+the relative finders all still work while cache is enabled."
+ (cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
+ (start-heading (org-edna-find-test-heading
"e57ce099-9f37-47f4-a6bb-61a84eb1fbbe"))
+ (org-todo-keywords '((sequence "TODO" "|" "DONE")))
+ ;; Only block based on Edna
+ (org-blocker-hook 'org-edna-blocker-function)
+ ;; Only trigger based on Edna
+ (org-trigger-hook 'org-edna-trigger-function)
+ ;; Enable cache
+ (org-edna-finder-use-cache t))
+ (org-with-point-at start-heading
+ (save-restriction
+ ;; Only allow operating on the current tree
+ (org-narrow-to-subtree)
+ ;; Show the entire subtree
+ (outline-show-all)
+ (unwind-protect
+ (let* ((heading1-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading2-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading3-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (heading4-pom (progn (org-next-visible-heading 1)
(point-marker))))
+ ;; Verify that headings 2, 3, and 4 are all blocked
+ (should (org-edna-test-check-block heading2-pom
+ "Initial attempt to change
heading 2"))
+ (should (org-edna-test-check-block heading3-pom
+ "Initial attempt to change
heading 3"))
+ (should (org-edna-test-check-block heading4-pom
+ "Initial attempt to change
heading 4"))
+ ;; Mark heading 1 as DONE
+ (should (not (org-edna-test-check-block heading1-pom
+ "Set heading 1 to DONE")))
+ ;; Only heading 2 should have a scheduled time
+ (should (string-equal (org-entry-get heading2-pom "SCHEDULED")
+ "<2000-01-15 Sat 01:00>"))
+ (should (not (org-entry-get heading3-pom "SCHEDULED")))
+ (should (not (org-entry-get heading4-pom "SCHEDULED")))
+ ;; The others should still be blocked.
+ (should (org-edna-test-check-block heading3-pom
+ "Second attempt to change
heading 3"))
+ (should (org-edna-test-check-block heading4-pom
+ "Second attempt to change
heading 4"))
+ ;; Try changing heading 2
+ (should (not (org-edna-test-check-block heading2-pom
+ "Set heading 2 to DONE")))
+ (should (string-equal (org-entry-get heading3-pom "SCHEDULED")
+ "<2000-01-16 Sun 09:00>"))
+ ;; 4 should still be blocked
+ (should (org-edna-test-check-block heading4-pom
+ "Second attempt to change
heading 4")))
+ ;; Change the test file back to its original state.
+ (org-edna-test-restore-test-file))))))
+
(ert-deftest org-edna-doc-test/nightly ()
(cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
(start-heading (org-edna-find-test-heading
"8b6d9820-d943-4622-85c9-4a346e033453"))
@@ -1772,6 +1896,47 @@ This avoids org-id digging into its internal database."
;; Change the test file back to its original state.
(org-edna-test-restore-test-file))))))
+(ert-deftest org-edna-doc-test/nightly-cache ()
+ (cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
+ (start-heading (org-edna-find-test-heading
"8b6d9820-d943-4622-85c9-4a346e033453"))
+ ;; Only use the test file in the agenda
+ (org-agenda-files `(,org-edna-test-file))
+ (org-todo-keywords '((sequence "TODO" "|" "DONE")))
+ ;; Only block based on Edna
+ (org-blocker-hook 'org-edna-blocker-function)
+ ;; Only trigger based on Edna
+ (org-trigger-hook 'org-edna-trigger-function)
+ ;; Enable cache
+ (org-edna-finder-use-cache t))
+ (org-with-point-at start-heading
+ (save-restriction
+ ;; Only allow operating on the current tree
+ (org-narrow-to-subtree)
+ ;; Show the entire subtree
+ (outline-show-all)
+ (unwind-protect
+ (let* ((nightly-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (lunch-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (door-pom (progn (org-next-visible-heading 1)
(point-marker)))
+ (dog-pom (progn (org-next-visible-heading 1)
(point-marker))))
+ ;; Verify that Nightly is blocked
+ (should (org-edna-test-check-block nightly-pom "Initial Nightly
Check"))
+ ;; Check off Lunch, and verify that nightly is still blocked
+ (org-edna-test-mark-done lunch-pom)
+ (should (org-edna-test-check-block nightly-pom "Nightly after
Lunch"))
+ ;; Check off Door, and verify that nightly is still blocked
+ (org-edna-test-mark-done door-pom)
+ (should (org-edna-test-check-block nightly-pom "Nightly after
Door"))
+ ;; Check off Dog. This should trigger the others.
+ (org-edna-test-mark-done dog-pom)
+ (should (org-edna-test-compare-todos lunch-pom "TODO" "Lunch
after Nightly Trigger"))
+ (should (org-edna-test-compare-todos door-pom "TODO" "Door after
Nightly Trigger"))
+ (should (org-edna-test-compare-todos dog-pom "TODO" "Dog after
Nightly Trigger"))
+ (should (string-equal (org-entry-get nightly-pom "DEADLINE")
+ "<2000-01-16 Sun +1d>")))
+ ;; Change the test file back to its original state.
+ (org-edna-test-restore-test-file))))))
+
(ert-deftest org-edna-doc-test/daily ()
(cl-letf* (((symbol-function 'current-time) (lambda () org-edna-test-time))
(start-heading (org-edna-find-test-heading
"630805bb-a864-4cdc-9a6f-0f126e887c66"))
diff --git a/org-edna.el b/org-edna.el
index 3247989..102dd06 100644
--- a/org-edna.el
+++ b/org-edna.el
@@ -583,6 +583,7 @@ following reasons:
(org-edna--add-to-finder-cache func-sym args)))))
+;;; Interactive Functions
(defmacro org-edna-run (change-plist &rest body)
"Run a TODO state change.
@@ -655,6 +656,7 @@ Remove Edna's workers from `org-trigger-hook' and
(remove-hook 'org-blocker-hook 'org-edna-blocker-function))
+;;; Finders
;; Tag Finder
(defun org-edna-finder/match (match-spec &optional scope skip)
@@ -1256,6 +1258,7 @@ which ones will and won't work."
(list (point-min-marker))))
+;;; Actions
;; Set TODO state
(defun org-edna-action/todo! (_last-entry new-state)
@@ -1882,6 +1885,7 @@ Does nothing if the source heading has no property
PROPERTY."
(org-entry-put nil property old-prop)))
+;;; Conditions
;; For most conditions, we return true if condition is true and neg is false,
or
;; if condition is false and neg is true:
@@ -1985,6 +1989,7 @@ starting from target's position."
(format "%s %s in %s" (if neg "Did Not Find" "Found") match
(buffer-name)))))
+;;; Consideration
(defun org-edna-handle-consideration (consideration blocks)
"Handle consideration CONSIDERATION.
@@ -2034,7 +2039,6 @@ same as \"consider\"."
first-block))))))
-
;;; Popout editing
(defvar org-edna-edit-original-marker nil)
@@ -2278,6 +2282,7 @@ Displays help for KEYWORD in the Help buffer."
(princ doc))))
+;;; Bug Reports
(declare-function lm-report-bug "lisp-mnt" (topic))
- [elpa] master updated (7cacd8a -> 76ef9bf), Ian Dunn, 2018/11/25
- [elpa] master a7286e6 03/13: Mention consider in opening of Consideration section, Ian Dunn, 2018/11/25
- [elpa] master 85b5f4e 04/13: Modified cache to only work for specific finders, Ian Dunn, 2018/11/25
- [elpa] master 9dea42d 02/13: Added note about naming conventions., Ian Dunn, 2018/11/25
- [elpa] master 0194996 01/13: Added org-edna-describe-keyword function, Ian Dunn, 2018/11/25
- [elpa] master 1bb1fed 08/13: Added timestamp sorting to relatives finder, Ian Dunn, 2018/11/25
- [elpa] master 2c5ac0c 12/13: Bumped version, Ian Dunn, 2018/11/25
- [elpa] master 58be309 06/13: Fixed up description of set-effort!., Ian Dunn, 2018/11/25
- [elpa] master c6b3234 07/13: Additional tests and minor cleanup,
Ian Dunn <=
- [elpa] master cb98c0f 10/13: Removed remnants of old build system, Ian Dunn, 2018/11/25
- [elpa] master 98651a0 09/13: Inverted definition of consideration, Ian Dunn, 2018/11/25
- [elpa] master 45310da 05/13: Various fixes from testing, Ian Dunn, 2018/11/25
- [elpa] master 26d2a0d 11/13: Added has-tags? and matches? conditions, Ian Dunn, 2018/11/25
- [elpa] master 76ef9bf 13/13: Merge commit '2c5ac0cb808ae6953fbc74cc497245dafb51051f', Ian Dunn, 2018/11/25