Get rid of :needs-ctx everywhere

This commit is contained in:
Michiel Borkent 2020-11-18 17:46:21 +01:00
parent 6ded59e6f1
commit 9cdd81c37b
6 changed files with 26 additions and 26 deletions

2
pods

@ -1 +1 @@
Subproject commit a0418d66229ec8cbf75ba44bd2abb0cf724deaa7
Subproject commit e71ae00d032c2af9b1e218835107f243f0ab9049

2
sci

@ -1 +1 @@
Subproject commit d5ec2099315ed8dc0321ba4444ca2b9638e05e6e
Subproject commit af30be059583c498b5deb65647131ae7b78f5669

View file

@ -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})

View file

@ -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)

View file

@ -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

View file

@ -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"))))))