jorgenschaefer / emacs-buttercup

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

:var does not work for defcustom? (Duplicate of #127) #206

Closed Trevoke closed 2 years ago

Trevoke commented 2 years ago

I have discovered in my test suite ( https://github.com/trevoke/org-gtd.el/ ) that I couldn't use :var org-gtd-directory to set the variable -- in my tests, it wouldn't be the correct value, it would be the default value. org-gtd-directory is a defcustom, so it has a default value that I was trying to change within a describe block.

So right now instead I accept that I am modifying the global scope and setting that variable with setq in a function called by before-all.

This is... Fine... But it lowers my overall trust in buttercup as a test runner :/

Here is sample code:

;; -*- lexical-binding: t; -*-

(require 'buttercup)
(require 'org-gtd)

(describe
 "Org GTD"

 :var ((org-gtd-directory (f-join default-directory "test"  "runtime-file-path")))

 (it "Creates a default file for each action where there isn't a refile target"
     (message org-gtd-directory)))

This prints out ~/gtd instead of ~/src/projects/org-gtd.el/test/runtime-file-path.

snogge commented 2 years ago

This looks like a duplicate of #127. Do you agree @Trevoke ?

Trevoke commented 2 years ago

I don't think so, because I have lexical binding enabled?

Trevoke commented 2 years ago

It's also possible I've actually misunderstood the flow of conversation in #127 and the core issue is still the dynamic scope, if so, then yes, I would agree it's a duplicate. I am not that familiar with emacs internals yet.

snogge commented 2 years ago

This is not about lexical binding, lexical binding is required for buttercup to work. I'm going to say that this is a Duplicate of #127 for now.

snogge commented 2 years ago

Duplicate of #127

snogge commented 2 years ago

Closing as a duplicate