An extra form before the ns form, on the same line as the ns form, breaks test detection.
enaeher opened this issue · 2 comments
Expected behavior
cider-test-run-test runs a test when the point is inside that test.
Actual behavior
cider-test-run-test gives the error "No test at point."
Steps to reproduce the problem
In a Clojure file containing an ns form and one of the forms in cider-test-defining-forms (e.g.: deftest), add a form before the ns form, on the same line. Then navigate the point to one of the test forms and run cider-test-run-test.
Here is an example of a namespace which will exhibit the problem:
1 (ns some-test
(:require [clojure.test :refer [deftest is]]))
(deftest unrecognized-test
(is (= 1 1)))Environment & Version information
CIDER version information
;; CIDER 1.5.0-snapshot (package: 20220731.522), nREPL 0.9.0
;; Clojure 1.11.1, Java 17.0.3
Lein / Clojure CLI version
Clojure CLI version 1.11.1.1165
Emacs version
GNU Emacs 28.2 (build 1, aarch64-apple-darwin21.6.0) of 2022-09-13
Operating system
MacOS Monterey 12.5.1
JDK distribution
openjdk version "17.0.3" 2022-04-19 LTS
OpenJDK Runtime Environment Corretto-17.0.3.6.1 (build 17.0.3+6-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.3.6.1 (build 17.0.3+6-LTS, mixed mode, sharing)
This boils down to
1 (ns some-test
(:require [clojure.test :refer [deftest is]]))being non-parseable by clojure-mode's (clojure-find-ns).
Funnily enough, the following does get detected properly:
1
(ns some-test
(:require [clojure.test :refer [deftest is]]))I'll transfer this issue to clojure-mode and see if we can get it fixed.
I gave this a fair shot, but I don't think there's a reasonable fix
Our clojure-namespace-regexp is defined as follows:
It only matches (ns if that's how a given line begins (line-start). I could remove that, but then other edge cases would begin failing.
It's simpler to recommend users to avoid writing incorrect / dubious code. Formatters and linters can help with that - it can be a good a idea to run them before running tests.
Cheers - V