Skip to content

Commit

Permalink
try to use buttercup's :var tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevoke committed Apr 23, 2023
1 parent f6a5bba commit b4e0c8c
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 75 deletions.
2 changes: 2 additions & 0 deletions test/archiving-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(describe
"archiving"

:var ((inhibit-message t))

(before-each
(ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))
Expand Down
2 changes: 2 additions & 0 deletions test/areas-of-focus.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"Areas of focus"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs)
(add-hook 'org-gtd-decorate-item-hooks #'org-gtd-areas-of-focus)
(setq org-gtd-areas-of-focus '("Health" "Home" "Career")))
Expand Down
2 changes: 2 additions & 0 deletions test/calendar-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"A calendar item"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
3 changes: 3 additions & 0 deletions test/clarify-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

(describe
"Flow for clarifying items"

:var ((inhibit-message t))

(it "stores a marker to the original heading as local variable in the WIP buffer"
(let ((source-buffer (ogt--temp-org-file-buffer "taskfile" "* This is the heading to clarify")))
(with-current-buffer source-buffer
Expand Down
2 changes: 2 additions & 0 deletions test/delegating-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"delegating a task"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
2 changes: 2 additions & 0 deletions test/files-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(describe
"Create a default file"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/gtd-file.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#+STARTUP: overview indent align inlineimages hidestars logdone logrepeat logreschedule logredeadline

#+STARTUP: overview indent align inlineimages hidestars

* Projects
:PROPERTIES:
Expand Down
47 changes: 27 additions & 20 deletions test/helpers/clarifying.el
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
(defun ogt-clarify-as-single-action ()
(execute-kbd-macro (kbd "C-c c s")))
(let ((inhibit-message t))
(execute-kbd-macro (kbd "C-c c s"))))

(defun ogt-clarify-as-project ()
(execute-kbd-macro (kbd "C-c c p")))
(let ((inhibit-message t))
(execute-kbd-macro (kbd "C-c c p"))))

(defun ogt-clarify-as-incubated-item (&optional date)
(let* ((date (or date (calendar-current-date)))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(execute-kbd-macro (kbd "C-c c i %s-%s-%s RET"))))
(let ((inhibit-message t))
(let* ((date (or date (calendar-current-date)))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(execute-kbd-macro (kbd "C-c c i %s-%s-%s RET")))))

(defun ogt-clarify-as-delegated-item (&optional to-whom date)
(let* ((person (or to-whom "Someone"))
(date (or date (calendar-current-date)))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(execute-kbd-macro (kbd (format "C-c c d %s RET %s-%s-%s RET" to-whom year month day)))))
(let ((inhibit-message t))
(let* ((person (or to-whom "Someone"))
(date (or date (calendar-current-date)))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(execute-kbd-macro (kbd (format "C-c c d %s RET %s-%s-%s RET" to-whom year month day))))))

(defun ogt-clarify-as-calendar-item (&optional date)
(let* ((date (or date (calendar-current-date)))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(execute-kbd-macro (kbd (format "C-c c c %s-%s-%s RET" year month day)))))
(let ((inhibit-message t))
(let* ((date (or date (calendar-current-date)))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(execute-kbd-macro (kbd (format "C-c c c %s-%s-%s RET" year month day))))))

(defun ogt-clarify-as-knowledge-item ()
(execute-kbd-macro (kbd "C-c c k")))
(let ((inhibit-message t))
(execute-kbd-macro (kbd "C-c c k"))))


(defun ogt-clarify-as-trash-item ()
(execute-kbd-macro (kbd "C-c c t")))
(let ((inhibit-message t))
(execute-kbd-macro (kbd "C-c c t"))))
73 changes: 41 additions & 32 deletions test/helpers/processing.el
Original file line number Diff line number Diff line change
@@ -1,56 +1,65 @@
(load "test/helpers/clarifying.el")

(defun ogt-capture-single-item (&optional label)
(org-gtd-capture nil "i")
(insert (or label "single action"))
(org-capture-finalize))
(let ((inhibit-message t))
(org-gtd-capture nil "i")
(insert (or label "single action"))
(org-capture-finalize)))

(defun ogt-capture-and-process-project (label)
"LABEL is the project label."
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(execute-kbd-macro (kbd "M-> RET"))
(with-current-buffer (current-buffer)
(insert ogt--project-text))
(ogt-clarify-as-project))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(execute-kbd-macro (kbd "M-> RET"))
(with-current-buffer (current-buffer)
(insert ogt--project-text))
(ogt-clarify-as-project)))

(defun ogt-capture-and-process-calendar-item (label &optional date)
"DATE has to be like the output of `calendar-current-date' so (MM DD YYYY)."
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-calendar-item date))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-calendar-item date)))

(defun ogt-capture-and-process-delegated-item (label &optional to-whom date)
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-delegated-item to-whom date))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-delegated-item to-whom date)))

(defun ogt-capture-and-process-incubated-item (label &optional date)
"LABEL is the incubated label."
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-incubated-item date))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-incubated-item date)))

(defun ogt-capture-and-process-single-action (label)
"LABEL is the single action label."
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-single-action))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-single-action)))

(defun ogt-capture-and-process-knowledge-item (label)
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-knowledge-item))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-knowledge-item)))

(defun ogt-capture-and-process-addition-to-project (label project-heading-simulated-input)
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)

(with-simulated-input project-heading-simulated-input
(org-gtd-organize--call
org-gtd-organize-add-to-project-func)))
(with-simulated-input project-heading-simulated-input
(org-gtd-organize--call
org-gtd-organize-add-to-project-func))))

(defun ogt-capture-and-process-trash-item (label)
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-trash-item))
(let ((inhibit-message t))
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-trash-item)))
3 changes: 2 additions & 1 deletion test/helpers/utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
(ogt--buffer-string (ogt--archive)))

(defun ogt--save-all-buffers ()
(with-simulated-input "!" (save-some-buffers)))
(let ((inhibit-message t))
(with-simulated-input "!" (save-some-buffers))))

(defun ogt--temp-org-file-buffer (basename &optional text)
"Create a new org-mode file with a unique name.
Expand Down
2 changes: 2 additions & 0 deletions test/horizons-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(describe
"Higher horizons"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
24 changes: 13 additions & 11 deletions test/incubate-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"An incubated item"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand All @@ -27,14 +29,14 @@
"compatibility with orgzly"
(it "has a copy of the active timestamp in the body"
(let* ((date (calendar-current-date))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(ogt-capture-and-process-incubated-item "Yowza" date)
(with-current-buffer (org-gtd--default-file)
(goto-char (point-min))
(search-forward "Yowza")
(org-end-of-meta-data t)
(expect (buffer-substring (point) (point-max))
:to-match
(format "<%s-%#02d-%#02d>" year month day)))))))
(year (nth 2 date))
(month (nth 0 date))
(day (nth 1 date)))
(ogt-capture-and-process-incubated-item "Yowza" date)
(with-current-buffer (org-gtd--default-file)
(goto-char (point-min))
(search-forward "Yowza")
(org-end-of-meta-data t)
(expect (buffer-substring (point) (point-max))
:to-match
(format "<%s-%#02d-%#02d>" year month day)))))))
2 changes: 2 additions & 0 deletions test/knowledge-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"Processing a knowledge item"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
2 changes: 2 additions & 0 deletions test/org-gtd-core-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"org-gtd-agenda-files"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
6 changes: 4 additions & 2 deletions test/organizing-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

(describe
"Organizing (in 3.0)"
(before-each
(ogt--configure-emacs))

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

(it "restores the window configuration"
Expand Down
1 change: 1 addition & 0 deletions test/processing-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
(describe
"Processing items"

:var ((inhibit-message t))

(before-each
(ogt--configure-emacs)
Expand Down
2 changes: 2 additions & 0 deletions test/project-modification-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"Modifying a project"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
3 changes: 2 additions & 1 deletion test/projects-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
(describe
"Project management"

(before-each (ogt--configure-emacs))
:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files)
;; TODO figure out if this can / should be removed
(remove-hook 'post-command-hook 'org-add-log-note))
Expand Down
3 changes: 3 additions & 0 deletions test/refiling-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

(describe
"When refiling a project"

:var ((inhibit-message t))

(before-each
(ogt--configure-emacs)
(ogt-capture-and-process-project "project headline")
Expand Down
15 changes: 10 additions & 5 deletions test/reviews-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
(describe
"Reviews"

:var ((inhibit-message t)
(org-gtd-areas-of-focus '("Health" "Home" "Career")))

(before-each (ogt--configure-emacs)
(add-hook 'org-gtd-decorate-item-hooks #'org-gtd-areas-of-focus)
(setq org-gtd-areas-of-focus '("Health" "Home" "Career")))
(add-hook 'org-gtd-decorate-item-hooks #'org-gtd-areas-of-focus))
(after-each (ogt--close-and-delete-files)
(remove-hook 'org-gtd-decorate-item-hooks #'org-gtd-areas-of-focus)
(setq org-gtd-areas-of-focus nil))
(remove-hook 'org-gtd-decorate-item-hooks #'org-gtd-areas-of-focus))

(describe
"Areas of focus"
(it "throws an error if called programmatically with an area not in the list"
(expect
(org-gtd-review-area-of-focus "Playing")
:to-throw
'org-gtd-invalid-area-of-focus))))
'org-gtd-invalid-area-of-focus))

(it "shows projects, next actions, habits, incubated items in agenda for a specific area of focus"
()
)))
2 changes: 2 additions & 0 deletions test/trash-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(describe
"Processing a trash item"

:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

Expand Down
4 changes: 3 additions & 1 deletion test/upgrades-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
(describe
"Upgrading org-gtd"

(before-each (ogt--configure-emacs))
:var ((inhibit-message t))

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

(describe
Expand Down
Loading

0 comments on commit b4e0c8c

Please sign in to comment.