diff --git a/clj/src/cljd/compiler.cljc b/clj/src/cljd/compiler.cljc index 35587916..639f21f5 100644 --- a/clj/src/cljd/compiler.cljc +++ b/clj/src/cljd/compiler.cljc @@ -256,7 +256,6 @@ (def ^:dynamic *host-eval* false) (def ^:dynamic ^String *lib-path* "lib/") -(def ^:dynamic ^String *test-path* "test/") (def ^:dynamic *target-subdir* "Relative path to the lib directory (*lib-dir*) where compiled dart file will be put. @@ -3236,7 +3235,8 @@ (defn emit-ns [[_ ns-sym & ns-clauses :as ns-form] _] (when (or (not *hosted*) *host-eval*) - (let [ns-clauses (drop-while #(or (string? %) (map? %)) ns-clauses) ; drop doc and meta for now + (let [[ns-meta ns-clauses] (split-with #(or (string? %) (map? %)) ns-clauses) + ns-meta (into {} (map #(if (string? %) [:doc %] % )) ns-meta) refer-clojures (if (= 'cljd.core ns-sym) [[:refer-clojure :only []]] (or (seq (filter #(= :refer-clojure (first %)) ns-clauses)) [[:refer-clojure]])) @@ -3262,8 +3262,9 @@ spec)))) ns-lib (ns-to-lib ns-sym) ns-map (-> ns-prototype - (assoc :lib ns-lib) - (assoc-in [:imports ns-lib] {:clj-alias (name ns-sym)})) + (assoc :meta ns-meta) + (assoc :lib ns-lib) + (assoc-in [:imports ns-lib] {:clj-alias (name ns-sym)})) ns-map (reduce #(%2 %1) ns-map (for [[lib & {:keys [as refer rename]}] require-specs @@ -4519,9 +4520,10 @@ (load-input in) (let [the-ns (@nses *current-ns*) libname (:lib the-ns) - is-test-ns (->> the-ns vals (some #(-> % :meta :dart/test))) + test-dir (some->> the-ns :meta :dart.test/dir (re-matches #"(.*?)/*") second) + is-test-ns (or (some? test-dir) (->> the-ns vals (some #(-> % :meta :dart/test)))) libname' (if is-test-ns - (str *test-path* (str/replace (subs libname (count *lib-path*)) #"\.dart$" "_test.dart")) + (str (or test-dir "test") "/" (str/replace (subs libname (count *lib-path*)) #"\.dart$" "_test.dart")) libname)] (when is-test-ns (swap! nses rename-lib libname libname'))