This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-26
Channels
- # babashka (7)
- # beginners (85)
- # calva (39)
- # cider (3)
- # clara (1)
- # clj-kondo (10)
- # clojure (194)
- # clojure-europe (36)
- # clojure-madison (2)
- # clojure-nl (13)
- # clojure-spec (11)
- # clojure-uk (2)
- # clojurescript (17)
- # community-development (5)
- # component (9)
- # conjure (4)
- # core-async (3)
- # cursive (32)
- # data-science (26)
- # datomic (31)
- # graalvm (22)
- # holy-lambda (31)
- # honeysql (7)
- # introduce-yourself (1)
- # jobs (9)
- # jobs-rus (1)
- # lsp (3)
- # malli (9)
- # off-topic (54)
- # pathom (27)
- # pedestal (6)
- # portal (1)
- # re-frame (4)
- # releases (1)
- # remote-jobs (1)
- # sci (3)
- # shadow-cljs (4)
- # spacemacs (13)
- # vim (14)
- # xtdb (3)
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!