Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update clojure-test-mode for leiningen test structure. #94

Merged
merged 1 commit into from

4 participants

@Imasius

Changed clojure-test-mode test structure to what leiningen is using atm.
Changed the keybinding to switch between test and implmentation to "C-c C-s".

Hi there,
as is started programming clojure three days ago (btw. my first lisp) i noticed that there are some differences between where leiningen expects test and where clojure-test-mode expect tests.
I saw the issues on the official repository and tried to fix them as a first exercise for lisp.
As i am fairly new to lisp, the code must be really bad. (Maybe introduced bugs?) Also i didn't updated the documentation for the new test paths.
I just want some feedback if these issues should be fixed at all and if so, what i have to do additionally, so that my code gets accepted.

Regards

@Imasius Imasius Changed clojure-test-mode test structure to what leiningen is using atm.
Changed the keybinding to switch between test and implmentation to "C-c C-s".
2be006f
@technomancy

Looks good; thanks.

Probably have enough breaking changes coming up that we'll bump the next release to 2.0.0.

@technomancy technomancy merged commit 80994d8 into clojure-emacs:master
@pjstadig
Owner

"-test$" really? ಠ_ಠ

@pjstadig
Owner

Is lein2's newnew generating project structures that expect this? I've never had a project that expects foo.bar-test as a test namespace.

@Imasius

As of preview7 of lein2 it generates foo.core and a foo.core-test (core_test.clj). So i assume that it works like Maven where the package structure is mirrored and "Test" appended to the class names.
But as i mentioned, i'm fairly new.

@pjstadig
Owner

hmm...

I'm not sure how wide spread it is, but for instance leiningen itself uses foo.test.bar not foo.bar-test. We also use foo.test.bar at work. I mean I guess if the convention is changing, then its changing. Not sure why.

@roman

Why is the "_test" convention being hard-coded? can this be parametrized?

I would take a patch to parameterize it; sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 8, 2012
  1. @Imasius

    Changed clojure-test-mode test structure to what leiningen is using atm.

    Imasius authored
    Changed the keybinding to switch between test and implmentation to "C-c C-s".
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 8 deletions.
  1. +4 −3 clojure-mode.el
  2. +6 −5 clojure-test-mode.el
View
7 clojure-mode.el
@@ -109,8 +109,8 @@ Clojure to load that file."
(define-key map "\C-c\C-e" 'lisp-eval-last-sexp)
(define-key map "\C-c\C-l" 'clojure-load-file)
(define-key map "\C-c\C-r" 'lisp-eval-region)
+ (define-key map (kbd "C-c C-s") 'clojure-jump-between-tests-and-code)
(define-key map "\C-c\C-z" 'clojure-display-inferior-lisp-buffer)
- (define-key map (kbd "C-c t") 'clojure-jump-to-test)
(define-key map (kbd "C-c M-q") 'clojure-fill-docstring)
map)
"Keymap for Clojure mode. Inherits from `lisp-mode-shared-map'.")
@@ -1172,7 +1172,7 @@ The arguments are dir, hostname, and port. The return value should be an `alist
;; Test navigation:
(defun clojure-in-tests-p ()
- (or (string-match-p "test\." (clojure-find-ns))
+ (or (string-match-p "-test$" (clojure-find-ns))
(string-match-p "/test" (buffer-file-name))))
(defun clojure-underscores-for-hyphens (namespace)
@@ -1183,7 +1183,8 @@ The arguments are dir, hostname, and port. The return value should be an `alist
(segments (split-string namespace "\\."))
(before (subseq segments 0 clojure-test-ns-segment-position))
(after (subseq segments clojure-test-ns-segment-position))
- (test-segments (append before (list "test") after)))
+ (newfile (format "%s_test" (car after)))
+ (test-segments (append before (list newfile))))
(mapconcat 'identity test-segments "/")))
(defun clojure-jump-to-test ()
View
11 clojure-test-mode.el
@@ -325,9 +325,10 @@ Retuns the problem overlay if such a position is found, otherwise nil."
(if (> 0 clojure-test-ns-segment-position)
(1- (+ (length segments) clojure-test-ns-segment-position))
clojure-test-ns-segment-position))
- (before (subseq segments 0 test-position))
- (after (subseq segments (1+ test-position)))
- (impl-segments (append before after)))
+ (before (subseq segments 0 clojure-test-ns-segment-position))
+ (after (subseq segments clojure-test-ns-segment-position))
+ (newfile (replace-regexp-in-string "_test$" "" (car after)))
+ (impl-segments (append before (list newfile))))
(mapconcat 'identity impl-segments "/")))
;; Commands
@@ -343,7 +344,7 @@ Retuns the problem overlay if such a position is found, otherwise nil."
(clojure-test-clear
(lambda (&rest args)
;; clojure-test-eval will wrap in with-out-str
- (clojure-test-eval (format "(clojure.core/load-file %s)"
+ (clojure-test-eval (format "(clojure.core/load-file \"%s\")"
(expand-file-name (buffer-file-name)))
(lambda (&rest args)
(clojure-test-eval "(binding [clojure.test/report
@@ -428,7 +429,7 @@ Retuns the problem overlay if such a position is found, otherwise nil."
(define-key map (kbd "C-c C-'") 'clojure-test-show-result)
(define-key map (kbd "C-c '") 'clojure-test-show-result)
(define-key map (kbd "C-c k") 'clojure-test-clear)
- (define-key map (kbd "C-c t") 'clojure-test-jump-to-implementation)
+ (define-key map (kbd "C-c C-s") 'clojure-jump-between-tests-and-code)
(define-key map (kbd "M-p") 'clojure-test-previous-problem)
(define-key map (kbd "M-n") 'clojure-test-next-problem)
map)
Something went wrong with that request. Please try again.