Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cider-test-run-test picks up the wrong var to test when using metadata #3758

Open
mbezjak opened this issue Nov 19, 2024 · 4 comments
Open

Comments

@mbezjak
Copy link

mbezjak commented Nov 19, 2024

Expected behavior

cider-test-run-test runs complex-metadata test.

Actual behavior

cider-test-run-test runs no-metadata test.

Steps to reproduce the problem

Create a fresh project with a test namespace.

(ns core-test
  (:require [clojure.test :refer [deftest is]]))

(deftest ^{:a 1} simple-metadata
  (println "simple-metadata")
  (is true))

(deftest ^{:a {}} complex-metadata
  (println "complex-metadata")
  (is true))

(deftest no-metadata
  (println "no-metadata")
  (is true))

Evaluate all forms and then

  1. if you run the test no-metadata -> all's good
  2. if you run the test simple-metadata -> all's good
  3. if you run the test complex-metadata -> it'll actually run the test no-metadata

The problem is likely with cider, because if I run the test with M-x nrepl-toggle-message-logging I see the following nrepl message

(-->
  id         "31"
  op         "test"
  session    "5592cda3-5c97-44d9-86ad-b4d240708b61"
  time-stamp "2024-11-19 22:25:08.377683423"
  fail-fast  "true"
  load?      "true"
  ns         #("core-test" 0 9 (face font-lock-type-face cider-block-dynamic-font-lock t cider-locals nil help-echo cider--help-echo fontified t))
  tests      ("no-metadata")
)

Meaning that cider actually picks up the wrong var to test.

Environment & Version information

CIDER version information

;; CIDER 1.16.0 (Kherson), nREPL 1.3.0
;; Clojure 1.11.1, Java 21.0.5

However, I've installed cider through melpa-unstable and it's installed in the directory cider-20241115.343. I.e. I'm running https://github.com/clojure-emacs/cider/tree/c228dec27df6b2c68262f17158208fe699e1ce02.

Emacs version

29.4

I haven't ruled out interaction with other emacs packages. Although, my initial guess is that it's unlikely.

Operating system

ArchLinux

@mbezjak
Copy link
Author

mbezjak commented Nov 19, 2024

If you can point me to the relevant code (and test), I can look into fixing this.

@vemv
Copy link
Member

vemv commented Nov 19, 2024

Interesting catch!

The Elisp-level parsing happens at (cider--extract-test-var-at-point)

@mbezjak
Copy link
Author

mbezjak commented Nov 19, 2024

Hmmm. I haven't debugged this thoroughly, but when I looked at the source code of (cider--extract-test-var-at-point), I found this nugget.

(clojure-find-def) ;; when the point is inside `complex-metadata`
=> ("deftest" "no-metadata")

Thanks for the hint, btw!

@vemv
Copy link
Member

vemv commented Nov 19, 2024

Nice! Then it's primarily an issue in https://github.com/clojure-emacs/clojure-mode , although it seems good to keep this one here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants