Get rid of :needs-ctx everywhere
This commit is contained in:
parent
6ded59e6f1
commit
9cdd81c37b
6 changed files with 26 additions and 26 deletions
2
pods
2
pods
|
|
@ -1 +1 @@
|
||||||
Subproject commit a0418d66229ec8cbf75ba44bd2abb0cf724deaa7
|
Subproject commit e71ae00d032c2af9b1e218835107f243f0ab9049
|
||||||
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit d5ec2099315ed8dc0321ba4444ca2b9638e05e6e
|
Subproject commit af30be059583c498b5deb65647131ae7b78f5669
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
(ns babashka.impl.pods
|
(ns babashka.impl.pods
|
||||||
{:no-doc true}
|
{:no-doc true}
|
||||||
(:refer-clojure :exclude [read])
|
(:refer-clojure :exclude [read])
|
||||||
(:require [babashka.pods.sci :as pods]))
|
(:require [babashka.impl.common :refer [ctx]]
|
||||||
|
[babashka.pods.sci :as pods]))
|
||||||
|
|
||||||
(def pods-namespace
|
(def pods-namespace
|
||||||
{'load-pod (with-meta pods/load-pod
|
{'load-pod (fn [& args]
|
||||||
{:sci.impl/op :needs-ctx})
|
(apply pods/load-pod @ctx args))
|
||||||
'invoke pods/invoke
|
'invoke pods/invoke
|
||||||
'unload-pod pods/unload-pod})
|
'unload-pod pods/unload-pod})
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
(ns babashka.impl.test
|
(ns babashka.impl.test
|
||||||
(:require [babashka.impl.clojure.test :as t]
|
(:require [babashka.impl.clojure.test :as t]
|
||||||
[sci.core :as sci]))
|
[babashka.impl.common :refer [ctx]]))
|
||||||
|
|
||||||
(defn macrofy [v]
|
(defn macrofy [v]
|
||||||
(with-meta v {:sci/macro true}))
|
(with-meta v {:sci/macro true}))
|
||||||
|
|
||||||
(defn contextualize [v]
|
(defn contextualize [f]
|
||||||
(with-meta v {:sci.impl/op :needs-ctx}))
|
(fn [& args]
|
||||||
|
(apply f @ctx args)))
|
||||||
|
|
||||||
(def clojure-test-namespace
|
(def clojure-test-namespace
|
||||||
{'*load-tests* t/load-tests
|
{'*load-tests* t/load-tests
|
||||||
|
|
@ -33,8 +34,7 @@
|
||||||
{:sci/macro true})
|
{:sci/macro true})
|
||||||
;; assertion macros
|
;; assertion macros
|
||||||
'is (with-meta @#'t/is
|
'is (with-meta @#'t/is
|
||||||
{;; :sci.impl/op :needs-ctx
|
{:sci/macro true})
|
||||||
:sci/macro true})
|
|
||||||
'are (macrofy @#'t/are)
|
'are (macrofy @#'t/are)
|
||||||
'testing (macrofy @#'t/testing)
|
'testing (macrofy @#'t/testing)
|
||||||
;; defining tests
|
;; defining tests
|
||||||
|
|
@ -49,8 +49,8 @@
|
||||||
;; running tests: low level
|
;; running tests: low level
|
||||||
'test-var t/test-var
|
'test-var t/test-var
|
||||||
'test-vars t/test-vars
|
'test-vars t/test-vars
|
||||||
'test-all-vars (with-meta t/test-all-vars {:sci.impl/op :needs-ctx})
|
'test-all-vars (contextualize t/test-all-vars)
|
||||||
'test-ns (with-meta t/test-ns {:sci.impl/op :needs-ctx})
|
'test-ns (contextualize t/test-ns)
|
||||||
;; running tests: high level
|
;; running tests: high level
|
||||||
'run-tests (contextualize t/run-tests)
|
'run-tests (contextualize t/run-tests)
|
||||||
'run-all-tests (contextualize t/run-all-tests)
|
'run-all-tests (contextualize t/run-all-tests)
|
||||||
|
|
|
||||||
|
|
@ -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 reflection-var (sci/new-dynamic-var '*warn-on-reflection* false))
|
||||||
|
|
||||||
(def load-file*
|
(defn load-file* [f]
|
||||||
(with-meta
|
|
||||||
(fn [sci-ctx f]
|
|
||||||
(let [f (io/file f)
|
(let [f (io/file f)
|
||||||
s (slurp f)]
|
s (slurp f)]
|
||||||
(sci/with-bindings {sci/ns @sci/ns
|
(sci/with-bindings {sci/ns @sci/ns
|
||||||
sci/file (.getAbsolutePath f)}
|
sci/file (.getAbsolutePath f)}
|
||||||
(sci/eval-string* sci-ctx s))))
|
(sci/eval-string* @common/ctx s))))
|
||||||
{:sci.impl/op :needs-ctx}))
|
|
||||||
|
|
||||||
(defn start-socket-repl! [address ctx]
|
(defn start-socket-repl! [address ctx]
|
||||||
(socket-repl/start-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?
|
(when-not stream?
|
||||||
{:sci.impl/deref! true}))] input-var)
|
{:sci.impl/deref! true}))] input-var)
|
||||||
(assoc-in ['clojure.main 'repl]
|
(assoc-in ['clojure.main 'repl]
|
||||||
^{:sci.impl/op :needs-ctx}
|
(fn [& opts]
|
||||||
(fn [ctx & opts]
|
|
||||||
(let [opts (apply hash-map opts)]
|
(let [opts (apply hash-map opts)]
|
||||||
(repl/start-repl! ctx opts)))))
|
(repl/start-repl! @common/ctx opts)))))
|
||||||
:env env
|
:env env
|
||||||
:features #{:bb :clj}
|
:features #{:bb :clj}
|
||||||
:classes classes/class-map
|
:classes classes/class-map
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,10 @@
|
||||||
(is v))))
|
(is v))))
|
||||||
|
|
||||||
(deftest download-and-extract-test
|
(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
|
(catch Exception e
|
||||||
(is (str/includes? (str e) "timed out"))))))
|
(is (str/includes? (str e) "timed out"))))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue