diff --git a/clojure-mode.el b/clojure-mode.el index f098dc83..029b55e9 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -365,6 +365,23 @@ in :db/id[:db.part/user]" (and (listp value) (every 'characterp value)))) +(defcustom clojure-test-dir-prefix "test" + "Used by clojure-test-for-fn to resolve a test namespace for the current +buffer. This is the path component between the project root and the test. +Leiningen puts sources and tests in /src and /test respectively. +Omit leading and trailing slashes!" + :type 'string + :group 'clojure + :safe 'stringp) + +(defcustom clojure-src-dir-prefix "src" + "The folder that contains the source namespaces. Used by +clojure-test-implementation-for to resolve a test namespace +to its corresponding source. Omit leading and trailing slashes!" + :type 'string + :group 'clojure + :safe 'stringp) + (defvar clojure-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map lisp-mode-shared-map) @@ -1173,9 +1190,10 @@ word test in it and whether the file lives under the test/ directory." "Return the path of the test file for the given NAMESPACE." (let* ((namespace (clojure-underscores-for-hyphens namespace)) (segments (split-string namespace "\\."))) - (format "%stest/%s_test.clj" + (format "%s/%s/%s_test.clj" (file-name-as-directory (locate-dominating-file buffer-file-name "src/")) + clojure-test-dir-prefix (mapconcat 'identity segments "/")))) (defvar clojure-test-for-fn 'clojure-test-for diff --git a/clojure-test-mode.el b/clojure-test-mode.el index 18487fe4..7fa2a9a0 100644 --- a/clojure-test-mode.el +++ b/clojure-test-mode.el @@ -328,8 +328,9 @@ Retuns the problem overlay if such a position is found, otherwise nil." (namespace-end (split-string (car (last segments)) "_")) (namespace-end (mapconcat 'identity (butlast namespace-end 1) "_")) (impl-segments (append (butlast segments 1) (list namespace-end)))) - (format "%s/src/%s.clj" + (format "%s/%s/%s.clj" (locate-dominating-file buffer-file-name "src/") + clojure-src-dir-prefix (mapconcat 'identity impl-segments "/")))) (defvar clojure-test-implementation-for-fn 'clojure-test-implementation-for