diff --git a/.gitignore b/.gitignore index 88b30b05..042d871d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ web/*.js web/out web/target-cljs .rebl -.shadow-cljs \ No newline at end of file +.shadow-cljs +.clj-kondo \ No newline at end of file diff --git a/deps.edn b/deps.edn index d796e21e..dfee13fa 100644 --- a/deps.edn +++ b/deps.edn @@ -26,7 +26,8 @@ :dev { :extra-paths ["dev"] :extra-deps { - org.clojure/tools.namespace {:mvn/version "1.3.0"} + io.github.tonsky/clj-reload {:mvn/version "0.4.3"} + io.github.tonsky/duti {:git/sha "78bbf61953b9a685d02ff8cc63d04e4e8da81eb9"} } } diff --git a/dev/data_readers.clj b/dev/data_readers.clj deleted file mode 100644 index 0dea6ab9..00000000 --- a/dev/data_readers.clj +++ /dev/null @@ -1 +0,0 @@ -{p user/p} \ No newline at end of file diff --git a/dev/user.clj b/dev/user.clj index 30c1e0ba..01dfbdae 100644 --- a/dev/user.clj +++ b/dev/user.clj @@ -1,54 +1,31 @@ (ns user (:require - [clojure.core.server :as server] - [clojure.java.io :as io] - [clojure.test :as t] - [clojure.tools.namespace.repl :as ns])) + [clj-reload.core :as reload] + [duti.core :as duti])) -(ns/set-refresh-dirs "src" "bench" "test" #_"bench_datomic" #_"test_datomic") +(reload/init + {:dirs ["src" "bench" "test" #_"bench_datomic" #_"test_datomic"] + :no-reload '#{user}}) -(defn reload [] +(defn reload [& [opts]] (set! *warn-on-reflection* true) - (let [res (ns/refresh)] - (if (instance? Throwable res) - (do - (.printStackTrace ^Throwable res) - (throw res)) - res))) - -(def lock - (Object.)) - -(defn position [] - (let [trace (->> (Thread/currentThread) - (.getStackTrace) - (seq)) - el ^StackTraceElement (nth trace 4)] - (str "[" (clojure.lang.Compiler/demunge (.getClassName el)) " " (.getFileName el) ":" (.getLineNumber el) "]"))) - -(defn p [form] - `(let [t# (System/currentTimeMillis) - res# ~form] - (locking lock - (println (str "#p" (position) " " '~form " => (" (- (System/currentTimeMillis) t#) " ms) " res#))) - res#)) + (let [res (reload/reload opts) + cnt (count (:loaded res))] + (str "Reloaded " cnt " namespace" (when (not= 1 cnt) "s")))) (defn -main [& args] - ;; setup repl (let [args (apply array-map args) - port (or - (some-> (get args "--port") parse-long) - (+ 1024 (rand-int 64512))) - file (io/file ".repl-port")] - (println "Started Server Socket REPL on port" port) - (spit file port) - (.deleteOnExit file) - (server/start-server - {:name "repl" - :port port - :accept 'clojure.core.server/repl - :server-daemon false}))) + ;; starting app + _ (set! *warn-on-reflection* true) + _ (require 'datascript.test) + ;; starting socket repl + port (some-> (get args "--port") parse-long) + _ (duti/start-socket-repl {:port port})])) (defn test-all [] (reload) - (t/run-all-tests #"datascript\..*")) \ No newline at end of file + (duti/test #"datascript\.test\..*")) + +(defn -test-main [_] + (reload {:only #"datascript\.test\..*"}) + (duti/test-exit #"datascript\.test\..*"))