jorgenschaefer / emacs-buttercup

Behavior-Driven Emacs Lisp Testing
GNU General Public License v3.0
360 stars 44 forks source link

Possible bug with *first test* run? #208

Closed Trevoke closed 2 years ago

Trevoke commented 2 years ago

reference code, which you should be able to clone and try yourself with eldev: https://github.com/Trevoke/org-gtd.el/commit/9f6117154ff4263cc341a0769ddfefc70c385022

basically, I have


(defcustom org-gtd-capture-templates
  '(("i" "Inbox"
     entry (file (lambda () (org-gtd-inbox-path)))
                 "* %?\n%U\n\n  %i"
                 :kill-buffer t))
  "Capture templates to be used when adding something to the inbox"
  :group 'org-gtd
  :type 'sexp
  :package-version "2.0.0")

(defun org-gtd-capture (&optional goto keys)
  "Capture something into the GTD inbox.
Wraps the function `org-capture' to ensure the inbox exists.
For GOTO and KEYS, see `org-capture' documentation for the variables of the same name."
  (interactive)
  (kill-buffer (org-gtd--inbox-file))

  (let ((org-capture-templates org-gtd-capture-templates))
    (org-capture goto keys)))

  (it "I dunno"
      (ogt--add-and-process-project "foo"))

  (it "archives completed and canceled projects"
      (ogt--add-and-process-project "project headline")

If I remove the "I dunno" then the "archives completed and canceled projects" fails. If I keep "I dunno" then "I dunno" fails but the other test passes.

It's the same failure in both cases:

Traceback (most recent call last):
  ogt--add-and-process-project("foo")
  org-gtd-capture(nil "i")
  (let ((org-capture-templates org-gtd-capture-templates)) (message "%s" org-capture-templates) (message (car (car org-capture-templates))) (org-capture goto keys))
  org-capture(nil "i")
  org-capture-select-template("i")
  error("No capture template referred to by \"%s\" keys" "i")
  signal(error ("No capture template referred to by \"i\" keys"))
error: (error "No capture template referred to by \"i\" keys")

Now... Weirdly enough, if I use "message" to print out the org-capture-templates variable, it is properly bound to the value of org-gtd-capture-templates.

There is some additional code so it's possible that it's on me but the fact that it's on the first test of the suite all the time makes me think it might be a buttercup issue?

Trevoke commented 2 years ago

Never mind, I don't know how to load features of org that I need before I use them.