Open Ambrevar opened 2 years ago
This makes sense. For me, usually I use FiveAM, and before a coding session I set up a Slite run with something like (fiveam:run :my-test-suite-name)
, so from that point onward I just do (C-c C-v .. or actually the undocumented C-c C-j, undocumented because it's a little buggy, to just run the previous test in my history).
But I think it makes sense to have a run-test-at-point. I wonder how we could make this work on both parachute and fiveam? Maybe make a reasonable guess looking up the tests from both fiveam and parachute?
I forgot to explain the use case: when the test suite is slow and you are working on the tests iteratively. You don't want to run the full suite every time because it takes too long.
About framework detection, maybe we could infer the suite based on the top-level first expression? Untested:
(defun slite-run-at-point (&optional raw-prefix-arg)
"See `sly-compile-defun' for RAW-PREFIX-ARG."
(interactive "P")
(call-interactively 'sly-compile-defun)
(slite-run
(cl-flet ((top-level-first-sexp
()
(ignore-errors
(save-excursion
(goto-char (car (sly-region-for-defun-at-point)))
(down-list 1)
(car (last (sly-parse-context (read (current-buffer)))))))))
(prin1-to-string
`(,(cond
((let ((case-fold-search t))
(string-match-p "define-test$" (symbol-name (top-level-first-sexp)) ))
'parachute:test)
(t
'fiveam:run))
,(let ((name (sly-parse-toplevel-form)))
(if (symbolp name)
`',(intern (sly-qualify-cl-symbol-name name))
name)))))))
A feature I miss with Parachute (I haven't tried FiveAM) is the ability to easily run the single test I'm writing (or "the test at point"). Unless I'm missing something, the quickest way is to switch to a repl and run
But if you do this a lot the back and forth switching quickly gets tiring...
Enters Slite with its convenient interface. Turns out that what I want fits in this very short function:
Now place the point on any test form and call
slite-run-at-point
.What do you think?