ADD a bunch of buffer status tests for actions

This commit is contained in:
Nathan Dwarshuis 2022-06-12 18:07:10 -04:00
parent d58c1b0458
commit ca17ee15d5
4 changed files with 170 additions and 68 deletions

38
init.el
View File

@ -1,42 +1,6 @@
;;;; init the straight package manager
;; disable automatic package updates
(setq straight-check-for-modifications nil)
;; watch for repo modifications if we have python3 and watchexec
;; otherwise just use a save hook
;; (setq straight-check-for-modifications
;; (if (and (executable-find "python3")
;; (executable-find "watchexec"))
;; '(watch-files find-when-checking)
;; '(check-on-save find-when-checking)))
;; add pinned packages to straight
;; (setq straight-profiles
;; '((nil . "default.el")
;; ;; Packages which are pinned to a specific commit.
;; (pinned . "pinned.el")))
;; bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; load experimental straight functions for pinning
;; (autoload #'straight-x-pull-all "straight-x")
;; (autoload #'straight-x-freeze-versions "straight-x")
;; install use-package itself
(straight-use-package 'use-package)
(load-file (expand-file-name "straight-boot.el" user-emacs-directory))
;; configure all config paths before anything else is loaded
(use-package no-littering :straight t)

View File

@ -193,7 +193,8 @@
;; date <-> epoch
(defun org-x-dag-datetime-to-epoch (date)
(float-time (encode-time `(0 ,@(reverse date) nil -1 nil))))
(-let (((y m d H M) date))
(float-time (encode-time (list 0 (or M 0) (or H 0) d m y nil -1 nil)))))
(defun org-x-dag-date-to-epoch (date)
(float-time (encode-time `(0 0 0 ,@(reverse date) nil -1 nil))))
@ -1092,7 +1093,7 @@ deadline (eg via epoch time) or if it has a repeater."
(_ nil)))
(lambda (next)
(pcase next
(`(:si-proj :proj-active ,d) (plist-get d :child-sched-dts))
(`(:si-proj :proj-active ,d) (plist-get d :child-scheds))
(`(:si-task :task-active ,d) (-some-> (plist-get d :sched) (list)))
(_ nil)))
(lambda (acc cs)

View File

@ -1,94 +1,96 @@
* TODO this is an active project
* projects
** TODO this is an active project
:PROPERTIES:
:ID: a98df83f-bc98-4767-b2bc-f1054dbf89f9
:CREATED: [2022-06-07 Tue 22:41]
:END:
** NEXT this is a project task
*** NEXT this is a project task
:PROPERTIES:
:ID: 2db32ed8-0a1f-488c-8e41-dd3549ac8b1b
:CREATED: [2022-06-07 Tue 22:41]
:END:
* TODO this is an active project (scheduled)
** TODO this is an active project (scheduled)
:PROPERTIES:
:ID: 3788c7bc-390e-4caf-af8e-06831ff3276b
:CREATED: [2022-06-10 Fri 19:29]
:END:
** TODO this is a scheduled task
*** TODO this is a scheduled task
SCHEDULED: <2022-06-10 Fri>
:PROPERTIES:
:ID: 19a7d558-e087-47ec-b686-feee29d352a1
:CREATED: [2022-06-10 Fri 19:29]
:END:
* TODO this is a waiting project
** TODO this is a waiting project
:PROPERTIES:
:ID: 26586b4d-7fc7-4a9f-b86f-e3c26a83a507
:CREATED: [2022-06-10 Fri 19:18]
:END:
** WAIT this is a waiting subtask
*** WAIT this is a waiting subtask
:PROPERTIES:
:ID: cf58280a-ac7c-4951-a3de-a3f79f92f2b0
:CREATED: [2022-06-10 Fri 19:18]
:END:
* HOLD this is a held project
** HOLD this is a held project
:PROPERTIES:
:ID: d5065c21-b717-41fe-8232-22afbd6b2243
:CREATED: [2022-06-10 Fri 19:14]
:END:
** TODO this is a subtask masked by a hold
*** TODO this is a subtask masked by a hold
:PROPERTIES:
:ID: ee9c6ec9-7626-40f5-9f06-3c91bc1338ed
:CREATED: [2022-06-10 Fri 19:14]
:END:
* TODO this is a project held by a subtask
** TODO this is a project held by a subtask
:PROPERTIES:
:ID: a771dc18-0c5f-4196-903d-ada3c8a9d817
:CREATED: [2022-06-10 Fri 19:15]
:END:
** HOLD this is a held subtask
*** HOLD this is a held subtask
:PROPERTIES:
:ID: 4f743d31-2df4-4e32-85de-cedae0cffeb2
:CREATED: [2022-06-10 Fri 19:15]
:END:
* TODO this is a stuck project
** TODO this is a stuck project
:PROPERTIES:
:CREATED: [2022-06-07 Tue 22:41]
:ID: c93fe96f-7130-4433-a960-98c07a3b21f4
:END:
** TODO this is a subtask
*** TODO this is a subtask
:PROPERTIES:
:ID: 2def43a3-e814-4793-adc7-38ddbbf30411
:CREATED: [2022-06-10 Fri 19:08]
:END:
* DONE this is a completed project
** DONE this is a completed project
CLOSED: [2022-06-10 Fri 19:10]
:PROPERTIES:
:ID: 87682ef6-cd4c-41a7-8f0d-6ac41e572b05
:CREATED: [2022-06-10 Fri 19:10]
:END:
** DONE this is a completed subtask
*** DONE this is a completed subtask
CLOSED: [2022-06-10 Fri 19:26]
:PROPERTIES:
:ID: 61866e72-7153-44d1-ae0f-af527fe5f9f4
:CREATED: [2022-06-10 Fri 19:10]
:END:
** CANC this is a cancelled task
*** CANC this is a cancelled task
CLOSED: [2022-06-10 Fri 19:26]
:PROPERTIES:
:ID: 322af50a-f431-4940-8caf-cc5acdf5a555
:CREATED: [2022-06-10 Fri 19:25]
:END:
* CANC this is a cancelled project
** CANC this is a cancelled project
CLOSED: [2022-06-10 Fri 19:13]
:PROPERTIES:
:ID: eca77dea-4a40-4697-a69d-d1ec798fe9ba
:CREATED: [2022-06-10 Fri 19:13]
:END:
** TODO this is a subtask masked by a cancel
*** TODO this is a subtask masked by a cancel
:PROPERTIES:
:ID: a834a585-acd1-44e9-8e62-17793146d6ab
:CREATED: [2022-06-10 Fri 19:13]
:END:
* TODO this is an iterator
* iterators
** TODO this is an iterator
:PROPERTIES:
:ID: 2711e9b9-f765-415d-930f-b7ff16b3140b
:CREATED: [2022-06-07 Tue 22:41]
@ -96,36 +98,112 @@ CLOSED: [2022-06-10 Fri 19:13]
:ARCHIVE: archive.org_archive::* something
:TIME_SHIFT: +1w
:END:
** TODO repeated thing
*** TODO repeated thing
SCHEDULED: <2022-06-07 Tue>
:PROPERTIES:
:ID: b02619f6-b9da-4d78-acdd-409a4c5d747b
:CREATED: [2022-06-07 Tue 22:41]
:END:
** TODO repeated thing
*** TODO repeated thing
SCHEDULED: <2022-06-14 Tue>
:PROPERTIES:
:ID: d1576921-41b6-4ca9-b775-8f4997983bc4
:CREATED: [2022-06-07 Tue 22:43]
:END:
** TODO repeated thing
*** TODO repeated thing
SCHEDULED: <2022-06-21 Tue>
:PROPERTIES:
:ID: a3653d7d-fd29-422e-83ac-06df2594c747
:CREATED: [2022-06-07 Tue 22:43]
:END:
* TODO this is a standalone task
** TODO this is an empty iterator
:PROPERTIES:
:ID: 15cfb339-358a-49ce-8cb3-9bcfb1c5a126
:CREATED: [2022-06-12 Sun 16:40]
:PARENT_TYPE: iterator
:ARCHIVE: archive.org_archive::* something
:TIME_SHIFT: +1w
:END:
** DONE this is a complete iterator
CLOSED: [2022-06-10 Fri 19:13]
:PROPERTIES:
:ID: f2002c13-5ddd-46ec-9895-67182d89dd19
:CREATED: [2022-06-12 Sun 16:44]
:PARENT_TYPE: iterator
:ARCHIVE: archive.org_archive::* something
:TIME_SHIFT: +1w
:END:
*** DONE subiter 1
CLOSED: [2022-06-10 Fri 19:13]
:PROPERTIES:
:ID: fa290644-ba9a-42ac-a25a-a0cca5704d44
:CREATED: [2022-06-12 Sun 16:44]
:END:
*** DONE subiter 2
CLOSED: [2022-06-12 Sun 16:44]
:PROPERTIES:
:ID: 4ec18d87-dda9-43a6-b5e3-4a633160cfec
:CREATED: [2022-06-12 Sun 16:44]
:END:
*** DONE subiter 3
CLOSED: [2022-06-12 Sun 16:44]
:PROPERTIES:
:ID: 30dfcebe-33e8-4190-9460-9bb439cb75e1
:CREATED: [2022-06-12 Sun 16:44]
:END:
** DONE this is a complete empty iterator
CLOSED: [2022-06-10 Fri 19:13]
:PROPERTIES:
:ID: 6ac25533-ba98-4cce-b8a3-9dcf2ada5d77
:CREATED: [2022-06-12 Sun 17:01]
:PARENT_TYPE: iterator
:ARCHIVE: archive.org_archive::* something
:TIME_SHIFT: +1w
:END:
** TODO iterator with projects
:PROPERTIES:
:ID: 6b33c33b-2ce8-405d-b2bb-917305dfa840
:CREATED: [2022-06-12 Sun 17:10]
:PARENT_TYPE: iterator
:ARCHIVE: archive.org_archive::* something
:TIME_SHIFT: +1w
:END:
*** TODO subiter project
:PROPERTIES:
:ID: ed5ff869-2d98-457e-8718-ebb0ca9c1e72
:CREATED: [2022-06-12 Sun 17:10]
:END:
**** TODO subsubiter task
SCHEDULED: <2022-06-12 Sun>
:PROPERTIES:
:ID: b49556a8-0ec3-487d-84bd-78bd29c9eaef
:CREATED: [2022-06-12 Sun 17:10]
:END:
**** TODO subsubiter task
SCHEDULED: <2022-06-14 Tue>
:PROPERTIES:
:ID: f6c2b3ff-66d6-418e-90ec-0d0643bd16ea
:CREATED: [2022-06-12 Sun 17:10]
:END:
* tasks
** TODO this is a standalone task
:PROPERTIES:
:ID: cda28b1a-2b7d-48ea-b1df-e006be799c2f
:CREATED: [2022-06-07 Tue 22:43]
:END:
* header with a nice tag :nice_tag:
* metadata tests
** header with a nice tag :nice_tag:
:PROPERTIES:
:ID: c5d3083b-7079-4f76-b8f8-0d994879d8f7
:CREATED: [2022-06-07 Tue 22:43]
:END:
** TODO task with nice tag
*** TODO task with nice parent tag
:PROPERTIES:
:ID: 3de25d74-b90e-4c77-9f7f-8190187e7ed0
:CREATED: [2022-06-07 Tue 22:43]
:END:
** TODO task with a random local tag :random_tag:
:PROPERTIES:
:ID: e4876e82-c8c8-4ff8-ad23-f78e3904b927
:CREATED: [2022-06-12 Sun 16:34]
:END:

View File

@ -19,17 +19,17 @@
;; run tests with this (in the org-x directory above this one):
;; emacs -batch -l ../../../init.el -l test/org-x-dag-test.el -f buttercup-run
;; emacs -batch -l init.el -l local/lib/org-x/test/org-x-dag-test.el -f buttercup-run
;;; Code:
(require 's)
(require 'either)
(require 'dash)
(require 'either)
(require 'org-x)
(defun setup ()
(setq org-directory "test/dag"
(setq org-directory (nd/expand-lib-directory "org-x/test/dag")
org-x-action-files (list "action1.org" "action2.org")
org-x-endpoint-goal-file "endpoint.org"
org-x-lifetime-goal-file "lifetime.org"
@ -256,7 +256,7 @@
nil nil nil :sp-proj '(:proj-complete)
'(:canceledp t :epoch 1654902780))))
(describe "Tasks"
(describe "Project Tasks"
(it "Active"
(expect "2db32ed8-0a1f-488c-8e41-dd3549ac8b1b" :id-to-be-action
nil nil nil :sp-task '(:task-active)
@ -282,6 +282,12 @@
nil nil nil :sp-task '(:task-complete)
'(:canceledp t :epoch 1654903560))))
(describe "Standalone Tasks"
(it "Active"
(expect "cda28b1a-2b7d-48ea-b1df-e006be799c2f" :id-to-be-action
nil nil nil :sp-task '(:task-active)
'(:sched nil :dead nil :todo "TODO"))))
(describe "Iterators"
(it "Active non-empty"
(let ((s0 (partition-timestamp "<2022-06-07 Tue>"))
@ -291,7 +297,60 @@
nil nil nil :sp-iter '(:iter-nonempty :nonempty-active)
(list :child-scheds `(,s0 ,s1 ,s2)
:leading-sched-dt (plist-get s2 :datetime)
:dead nil)))))))
:dead nil))))
(it "Active non-empty (with project)"
(let ((s0 (partition-timestamp "<2022-06-12 Tue>"))
(s1 (partition-timestamp "<2022-06-14 Tue>")))
(expect "6b33c33b-2ce8-405d-b2bb-917305dfa840" :id-to-be-action
nil nil nil :sp-iter '(:iter-nonempty :nonempty-active)
(list :child-scheds `(,s0 ,s1)
:leading-sched-dt (plist-get s1 :datetime)
:dead nil))))
(it "Active empty"
(expect "15cfb339-358a-49ce-8cb3-9bcfb1c5a126" :id-to-be-action
nil nil nil :sp-iter '(:iter-empty :empty-active) nil))
(it "Complete non-empty"
(expect "f2002c13-5ddd-46ec-9895-67182d89dd19" :id-to-be-action
nil nil nil :sp-iter '(:iter-nonempty :nonempty-complete)
'(:canceledp nil :epoch 1654902780)))
(it "Active empty"
(expect "6ac25533-ba98-4cce-b8a3-9dcf2ada5d77" :id-to-be-action
nil nil nil :sp-iter '(:iter-empty :empty-complete)
'(:canceledp nil :epoch 1654902780))))
(describe "Sub-iterators"
(it "Active task"
(let ((s (partition-timestamp "<2022-06-07 Tue>")))
(expect "b02619f6-b9da-4d78-acdd-409a4c5d747b" :id-to-be-action
nil nil nil :sp-subiter '(:si-task :task-active)
(list :sched s :dead nil))))
(it "Complete task"
(expect "fa290644-ba9a-42ac-a25a-a0cca5704d44" :id-to-be-action
nil nil nil :sp-subiter '(:si-task :task-complete)
'(:canceledp nil :epoch 1654902780)))
(it "Active project"
(let ((s0 (partition-timestamp "<2022-06-12 Sun>"))
(s1 (partition-timestamp "<2022-06-14 Sun>")))
(expect "ed5ff869-2d98-457e-8718-ebb0ca9c1e72" :id-to-be-action
nil nil nil :sp-subiter '(:si-proj :proj-active)
(list :dead nil
:child-scheds `(,s0 ,s1)
:leading-sched-dt (plist-get s1 :datetime)))))))
(describe "Metadata Tests"
(it "parent tag"
(expect (org-x-dag-id->tags "3de25d74-b90e-4c77-9f7f-8190187e7ed0")
:to-equal '("nice_tag")))
(it "local tag"
(expect (org-x-dag-id->local-tags "e4876e82-c8c8-4ff8-ad23-f78e3904b927")
:to-equal '("random_tag")))))
(provide 'org-x-dag-test)
;;; org-x-dag-test.el ends here