liquidz / vim-iced

Clojure Interactive Development Environment for Vim8/Neovim
https://liquidz.github.io/vim-iced/
MIT License
518 stars 35 forks source link

Custom test form names for State Flow #364

Closed guilhermedallanol closed 2 years ago

guilhermedallanol commented 3 years ago

Hey everyone, me again.

The company that I'm currently working developed its own testing framework called state-flow. When I try to run one of those tests, I get this error:

 Unable to resolve symbol: defflow in this context

After asking around, they told me that for conjure, they solve this problem with this:

let g:conjure#client#clojure#nrepl#test#current_form_names = ['deftest', 'defflow']

I couldn't find anything related to this in the docs. Any ideas on how to solve that?

Thank you!

liquidz commented 3 years ago

@guilhermedallanol In my environment, state-flow works.

(ns foo.core-test
  (:require
    [state-flow.api :refer [defflow match?]]))

;; run :IcedTestUnderCursor in the next form
(defflow test-flow
  (match? 1 1))

(meta #'test-flow) ;; => {:test #function[foo.core-test/fn--16175], ....}

vim-iced uses metadata to check the current form is test or not. And defflow defines a var with :test metadata as same as clojure.test/deftest, so vim-iced can handle vars with defflow as test vars.

BTW, I found a bug in the handling of errors in the state-flow test, so I'll fix it.

liquidz commented 3 years ago

BTW, I found a bug in the handling of errors in the state-flow test, so I'll fix it.

More specifically, it was a bug about handling test results which does not contain file path information. I've fixed it in dev branch for now. https://github.com/liquidz/vim-iced/tree/dev

guilhermedallanol commented 3 years ago

@liquidz I just noticed what I was doing wrong. The :require was only allowing flow instead of both flow and defflow. When I added defflow it worked as expected.

Thank you again!