diff --git a/pods b/pods index a0418d66..e71ae00d 160000 --- a/pods +++ b/pods @@ -1 +1 @@ -Subproject commit a0418d66229ec8cbf75ba44bd2abb0cf724deaa7 +Subproject commit e71ae00d032c2af9b1e218835107f243f0ab9049 diff --git a/sci b/sci index d5ec2099..af30be05 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit d5ec2099315ed8dc0321ba4444ca2b9638e05e6e +Subproject commit af30be059583c498b5deb65647131ae7b78f5669 diff --git a/src/babashka/impl/pods.clj b/src/babashka/impl/pods.clj index 28911127..d7e579f2 100644 --- a/src/babashka/impl/pods.clj +++ b/src/babashka/impl/pods.clj @@ -1,10 +1,11 @@ (ns babashka.impl.pods {:no-doc true} (:refer-clojure :exclude [read]) - (:require [babashka.pods.sci :as pods])) + (:require [babashka.impl.common :refer [ctx]] + [babashka.pods.sci :as pods])) (def pods-namespace - {'load-pod (with-meta pods/load-pod - {:sci.impl/op :needs-ctx}) + {'load-pod (fn [& args] + (apply pods/load-pod @ctx args)) 'invoke pods/invoke 'unload-pod pods/unload-pod}) diff --git a/src/babashka/impl/test.clj b/src/babashka/impl/test.clj index 7ce6acdf..331b72a5 100644 --- a/src/babashka/impl/test.clj +++ b/src/babashka/impl/test.clj @@ -1,12 +1,13 @@ (ns babashka.impl.test - (:require [babashka.impl.clojure.test :as t] - [sci.core :as sci])) + (:require [babashka.impl.clojure.test :as t] + [babashka.impl.common :refer [ctx]])) (defn macrofy [v] (with-meta v {:sci/macro true})) -(defn contextualize [v] - (with-meta v {:sci.impl/op :needs-ctx})) +(defn contextualize [f] + (fn [& args] + (apply f @ctx args))) (def clojure-test-namespace {'*load-tests* t/load-tests @@ -33,8 +34,7 @@ {:sci/macro true}) ;; assertion macros 'is (with-meta @#'t/is - {;; :sci.impl/op :needs-ctx - :sci/macro true}) + {:sci/macro true}) 'are (macrofy @#'t/are) 'testing (macrofy @#'t/testing) ;; defining tests @@ -49,8 +49,8 @@ ;; running tests: low level 'test-var t/test-var 'test-vars t/test-vars - 'test-all-vars (with-meta t/test-all-vars {:sci.impl/op :needs-ctx}) - 'test-ns (with-meta t/test-ns {:sci.impl/op :needs-ctx}) + 'test-all-vars (contextualize t/test-all-vars) + 'test-ns (contextualize t/test-ns) ;; running tests: high level 'run-tests (contextualize t/run-tests) 'run-all-tests (contextualize t/run-all-tests) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 89cc05b6..d2d5f123 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -308,15 +308,12 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that (def reflection-var (sci/new-dynamic-var '*warn-on-reflection* false)) -(def load-file* - (with-meta - (fn [sci-ctx f] - (let [f (io/file f) - s (slurp f)] - (sci/with-bindings {sci/ns @sci/ns - sci/file (.getAbsolutePath f)} - (sci/eval-string* sci-ctx s)))) - {:sci.impl/op :needs-ctx})) +(defn load-file* [f] + (let [f (io/file f) + s (slurp f)] + (sci/with-bindings {sci/ns @sci/ns + sci/file (.getAbsolutePath f)} + (sci/eval-string* @common/ctx s)))) (defn start-socket-repl! [address ctx] (socket-repl/start-repl! address ctx) @@ -544,10 +541,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that (when-not stream? {:sci.impl/deref! true}))] input-var) (assoc-in ['clojure.main 'repl] - ^{:sci.impl/op :needs-ctx} - (fn [ctx & opts] + (fn [& opts] (let [opts (apply hash-map opts)] - (repl/start-repl! ctx opts))))) + (repl/start-repl! @common/ctx opts))))) :env env :features #{:bb :clj} :classes classes/class-map diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 68c6e29b..2890309c 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -465,7 +465,10 @@ (is v)))) (deftest download-and-extract-test - (is (try (= 6 (bb nil (io/file "test" "babashka" "scripts" "download_and_extract_zip.bb"))) + ;; Disabled because Github throttles bandwidth and this makes for a very slow test. + ;; TODO: refactor into individual unit tests + ;; One for downloading a small file and one for unzipping. + #_(is (try (= 6 (bb nil (io/file "test" "babashka" "scripts" "download_and_extract_zip.bb"))) (catch Exception e (is (str/includes? (str e) "timed out"))))))