Search code examples
pluginsclojurespecificationsleiningen

Cannot get instrumentable syms in project via Leiningen plugin


I'm trying to write a leiningen plugin based upon clojure.spec.alpha. Among other things, I want to get all of the functions in the project that have been spec'd. This is done by calling instrumentable-syms in clojure.spec.test.alpha. I have a function within my plugin that does this, but when run in the context of another project (via eval-in-project), the list of instrumentable syms is empty. I suspect this is because the calls to fdef within the project using the plugin, which are generally top-level forms within the source files and which register the specs, are not being evaluated and are thus not being picked up when calling instrumentable-syms.

My question is then, how do I make sure these calls get evaluated so my plugin can find all the spec'd functions in a project.


Solution

  • Try doing something to load the relevant namespaces and thus bring your program "to life", perhaps if you have a file like src/orgname/project/core.clj then you might try calling:

    (load "orgname/project/core")
    

    From within the block of code run in the project.