Re: Determine file of auxiliary test method with clojure.test?

2014-07-14 Thread Colin Fleming
So this was definitely non-obvious, but I did manage to make it work. I
overrode do-report (with with-redefs since it's not dynamic) and then used
the stack frame trick as Jeff suggested. I did also have to de-munge the
class name since the file from the stack trace element is only the file
short name, not the complete path - I used the class name to disambiguate.
It's fairly ugly but it does seem to work.

Thanks,
Colin


On 11 July 2014 03:12, Jeff Valk jv-li...@tx.rr.com wrote:

 You could override the clojure.test/do-report implementation and use the
 same stack frame trick that the default :fail case uses. Then from there,
 either use the file name from the StackTraceElement, or demunge the
 method name to get the var. I wouldn't really call that obvious, though.
 :-)

 Cheers,
 Jeff

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Determine file of auxiliary test method with clojure.test?

2014-07-13 Thread Colin Fleming
Hi Jeff,

Sorry for the late reply - that's great, thanks very much, looks like I can
hack something together with that.

Cheers,
Colin


On 11 July 2014 03:12, Jeff Valk jv-li...@tx.rr.com wrote:

 You could override the clojure.test/do-report implementation and use the
 same stack frame trick that the default :fail case uses. Then from there,
 either use the file name from the StackTraceElement, or demunge the
 method name to get the var. I wouldn't really call that obvious, though.
 :-)

 Cheers,
 Jeff

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Determine file of auxiliary test method with clojure.test?

2014-07-10 Thread Colin Fleming
Hi all,

Cursive provides test functionality that paints pass/fail markers in the
editors when tests are running. This all works great, except when someone
defines a test that calls a function containing is forms in another
namespace. An example:

(ns foo.core-test
  (:require [clojure.test :refer :all]
[foo.test-helper :as helper]))
(deftest a-test
  (helper/test-something))

and

(ns foo.test-helper
  (:require [clojure.test :refer [is]]))
(defn test-something []
  (is (= 42 42)))

I'm overriding clojure.test/report, but I can't see any way to determine
when I receive the :pass message that the test is actually in another file.
The :begin-test-var event contains the a-test var, but that's in the wrong
file. The :pass event contains the :expected form, but the meta for that
only contains :line and :column, not :file.

Am I missing something obvious?

Thanks,
Colin

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Determine file of auxiliary test method with clojure.test?

2014-07-10 Thread Jeff Valk
You could override the clojure.test/do-report implementation and use the 
same stack frame trick that the default :fail case uses. Then from there, 
either use the file name from the StackTraceElement, or demunge the method 
name to get the var. I wouldn't really call that obvious, though. :-)

Cheers,
Jeff

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.