Hello! Is there a good way to find all currently instrumented vars? It looks like (st/unstrument) will return anything that has been unstrumented, so that's a way to tell (sort-of), but for our use-case we'd like to:
• Preserve current instrumentation state
• Instrument all vars
• Do something
• Restore previous instrumentation state
Which allows us to enable instrumentation when, e.g., running tests but keeping any instrumentation state in the REPL
Looks like no, unless you want to access a private var and risk breakage later. The instrumented vars are kept in a global atom. https://github.com/clojure/spec.alpha/blob/f23ea614b3cb658cff0044a027cacdd76831edcf/src/main/clojure/clojure/spec/test/alpha.clj#L150
isn't there a function for this in stest?
Doesn't appear to be. There's one that does the opposite though, turning off instrumentation within a dynamic scope.
There's instrumentable-syms and checkable-syms but I guess not instrumented-syms
Yep 🙂 instrumented-syms would have been perfect
Right now we basically have:
(let [currently-instrumented-vars (st/unstrument)]
(set/difference (set (st/instrument)) (set currently-instrumented-vars)))
As a way to figure out what syms we should restoreA with-instrument-enabled macro parallel to the with-instrument-disabled would have been pretty slick, to let this be done in a call scope rather than with global state changes.
feel free to file requests at https://ask.clojure.org ...
Will do -- thanks!
https://ask.clojure.org/index.php/11816/support-checking-instrumented-syms-clojure-spec-test-alpha