Autotest doesn't reload files with reader conditionals #339

Open
frerom opened this Issue Nov 11, 2015 · 5 comments

Projects

None yet

5 participants

@frerom
frerom commented Nov 11, 2015

I use Midje to test a ClojureScript project, this is made possible with reader conditionals. Testing a .cljc file with pure Clojure content works as it should. But as soon as you involve reader conditionals, i.e. #?(..), with the namespace declaration Midje stops watching that file. Note that using reader conditionals further down the file (that doesn't involve ns) works perfectly fine.

; This doesn't work
#?(:cljs (ns foo.bar (:require [foo.baz]))
   :clj  (ns foo.bar))

; This doesn't work either
(ns foo.bar
  #?(:cljs (:require [foo.baz])))

; This works
(ns foo.bar)
#?(:cljs (def foo "bar")
   :clj  (def foo "baz"))

Midje will run the tests successfully at init, the problem is that the source file isn't recompiled when changed. The file isn't listed in the print out "Loading (< namespaces >)" either.

Does anyone know what might be causing this?

@markmandel

Thanks for reporting this - just ran into exactly the same issue. +1.

@marick
Owner
marick commented Dec 21, 2015

Apologies for slowness, and also apologies for being ignorant of Clojurescript and conditional readers. I tried the following with Clojure 1.7:

(ns scratch.core2
  (:use midje.sweet)
  (:require [scratch.core])
  (:require [scratch.core :as generic]))


#?(:cljs (def foo "bar")
   :clj  (def foo "baz"))

When I do lein midje, I get this:

Exception in thread "main" java.lang.RuntimeException: Conditional read not allowed, compiling:(scratch/core2.clj:7:3)

What am I doing wrong?

@marick
Owner
marick commented Dec 21, 2015

Without the #? form, everything works:

666 $ lein midje
This is from the Midje configuration file in ${HOME}.
= Namespace scratch.t-core
Clojure version  {:major 1, :minor 7, :incremental 0, :qualifier nil}
= Namespace scratch.t-core2
= Namespace scratch.core2
All checks (1) succeeded.
@arronmabrey

@marick I believe reader conditionals are only allowed in files with the .cljc extension. The exception shows a file with .clj e.g. scratch/core2.clj

Here is a link to more resources
https://github.com/clojure/clojurescript/wiki/Using-cljc

@viebel
viebel commented Feb 18, 2017

I'd love to work on this issue.
@marick Could you guide me regarding how could I solve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment