Compare commits
20 commits
master
...
benjamin-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
663052bda3 | ||
|
|
631f54e4e2 | ||
|
|
89e1351456 | ||
|
|
f58c0fcff4 | ||
|
|
e933a5aef3 | ||
|
|
9a6f48b986 | ||
|
|
73805703a2 | ||
|
|
5f0a822a55 | ||
|
|
a05004b9a2 | ||
|
|
5f3da77669 | ||
|
|
74b6b736d5 | ||
|
|
6bb48134f4 | ||
|
|
07a0c03593 | ||
|
|
8f96f23e35 | ||
|
|
4db8f7cc92 | ||
|
|
15df72344d | ||
|
|
0dd55dc556 | ||
|
|
4cfe188861 | ||
|
|
60af6a3a94 | ||
|
|
dbb28b86e1 |
21 changed files with 277 additions and 118 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit ad763a78f1bc327a493ff0b650aa5408ecbf4819
|
Subproject commit 52a5a2daa4cc048c8d5d93a36e0ac05d52dfa21d
|
||||||
2
deps.clj
2
deps.clj
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9bae77d5b346089f4fd2108933971c5a342ed39e
|
Subproject commit 2f93fe8ba712c855feb6ecf26d2ed70646b34356
|
||||||
6
deps.edn
6
deps.edn
|
|
@ -31,7 +31,7 @@
|
||||||
org.clojure/data.csv {:mvn/version "1.0.0"},
|
org.clojure/data.csv {:mvn/version "1.0.0"},
|
||||||
cheshire/cheshire {:mvn/version "5.11.0"}
|
cheshire/cheshire {:mvn/version "5.11.0"}
|
||||||
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
|
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
|
||||||
clj-commons/clj-yaml {:mvn/version "0.7.169"}
|
clj-commons/clj-yaml {:mvn/version "1.0.26"}
|
||||||
com.cognitect/transit-clj {:mvn/version "1.0.333"}
|
com.cognitect/transit-clj {:mvn/version "1.0.333"}
|
||||||
org.clojure/test.check {:mvn/version "1.1.1"}
|
org.clojure/test.check {:mvn/version "1.1.1"}
|
||||||
nrepl/bencode {:mvn/version "1.1.0"}
|
nrepl/bencode {:mvn/version "1.1.0"}
|
||||||
|
|
@ -50,8 +50,8 @@
|
||||||
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
||||||
insn/insn {:mvn/version "0.5.2"}
|
insn/insn {:mvn/version "0.5.2"}
|
||||||
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
||||||
org.babashka/cli {:mvn/version "0.6.50"}
|
org.babashka/cli {:mvn/version "0.7.51"}
|
||||||
org.babashka/http-client {:mvn/version "0.1.8"}
|
org.babashka/http-client {:mvn/version "0.2.9"}
|
||||||
;; native image bloat with ordered 1.5.10
|
;; native image bloat with ordered 1.5.10
|
||||||
org.flatland/ordered {:mvn/version "1.5.9"}}
|
org.flatland/ordered {:mvn/version "1.5.9"}}
|
||||||
:aliases {:babashka/dev
|
:aliases {:babashka/dev
|
||||||
|
|
|
||||||
49
doc/news.md
49
doc/news.md
|
|
@ -5,6 +5,55 @@ you have anything to add. Also see
|
||||||
[#babashka](https://twitter.com/hashtag/babashka?src=hashtag_click&f=live) on
|
[#babashka](https://twitter.com/hashtag/babashka?src=hashtag_click&f=live) on
|
||||||
Twitter.
|
Twitter.
|
||||||
|
|
||||||
|
## 2023-03 ([Twitter](https://twitter.com/search?q=(%23babashka%20OR%20babashka)%20since%3A2023-03-01%20until%3A2023-04-01&src=typed_query&f=top), [Mastodon](https://mastodon.social/tags/babashka))
|
||||||
|
|
||||||
|
### Releases
|
||||||
|
|
||||||
|
1.3.176, 1.3.175, 1.2.174:
|
||||||
|
|
||||||
|
Biggest highlight: Switch to GraalVM 19 and enable virtual threads!
|
||||||
|
|
||||||
|
### Videos
|
||||||
|
|
||||||
|
- [Blambda! The sound of babashka and AWS colliding](https://pitch.com/public/03fa9c7e-2b0e-45fb-8a22-d4a4d4d79d24), by Josh Glover from Pitch!
|
||||||
|
|
||||||
|
### Projects
|
||||||
|
|
||||||
|
- [babashka.json](https://github.com/babashka/json): JSON abstraction library
|
||||||
|
- [martian](https://github.com/oliyh/martian) is now babashka compatible!
|
||||||
|
- [panas.reload](https://github.com/keychera/panas.reload): a hot reload for babashka serving html+css (or htmx)
|
||||||
|
- [cljs-exif-reader](https://git.sr.ht/~rwv/cljs-exif-reader): Extract information from TIFF and JPEG images (works in babashka, despite the name)
|
||||||
|
|
||||||
|
### Jobs
|
||||||
|
|
||||||
|
- Write babashka at [Cognician](https://twitter.com/RobStuttaford/status/1641694501793038336)!
|
||||||
|
|
||||||
|
## 2023-02 ([Twitter](https://twitter.com/search?q=(%23babashka%20OR%20babashka)%20since%3A2023-02-01%20until%3A2023-03-01&src=typed_query&f=live), [Mastodon](https://mastodon.social/tags/babashka))
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
|
1.1.173: mostly bugfixes
|
||||||
|
|
||||||
|
### Articles
|
||||||
|
|
||||||
|
- [A technique for live coding simple web pages](https://github.com/whacked/cow/blob/main/a%20technique%20for%20live%20coding%20simple%20web%20pages.md) with babashka
|
||||||
|
|
||||||
|
### Videos
|
||||||
|
|
||||||
|
- [Stockholm Clojure Meetup Feb 23: Blambda! The sound of Babashka and Lambda colliding](https://www.youtube.com/watch?v=NfgYon96dsE)
|
||||||
|
|
||||||
|
### Projects
|
||||||
|
|
||||||
|
- [debux](https://github.com/philoskim/debux) is now babaskha-compatible
|
||||||
|
- [lines-of-code-bb](https://github.com/matthewdowney/linesofcode-bb): Babashka script to count lines of Clojure code, docs, comments, and more
|
||||||
|
- [deps-try](https://github.com/eval/deps-try): a babashka-script to try out Clojure libraries in rebel-readline
|
||||||
|
- [bb-dialog](https://github.com/pixelated-noise/bb-dialog) adds support for `--treeview`
|
||||||
|
- [A duckduck go CLI with babashka and (bbl)gum](https://mastodon.me.uk/@choffee/109845697304457129)
|
||||||
|
- [babashka http-client](https://github.com/babashka/http-client) now supports multipart uploads
|
||||||
|
- [sublime-pretty-edn](https://github.com/oakmac/sublime-pretty-edn): Format, Validate, Minify EDN files in Sublime Text
|
||||||
|
- [Play console tetris in babashka!](https://twitter.com/borkdude/status/1628473136969576449)
|
||||||
|
- [kaocha test runner](https://github.com/lambdaisland/kaocha) became babashka compatible!
|
||||||
|
|
||||||
## 2023-01 ([Twitter](https://twitter.com/search?q=%28%23babashka%20OR%20babashka%29%20until%3A2023-02-01%20since%3A2023-01-01&src=typed_query&f=live), [Mastodon](https://mastodon.social/tags/babashka))
|
## 2023-01 ([Twitter](https://twitter.com/search?q=%28%23babashka%20OR%20babashka%29%20until%3A2023-02-01%20since%3A2023-01-01&src=typed_query&f=live), [Mastodon](https://mastodon.social/tags/babashka))
|
||||||
|
|
||||||
### Releases
|
### Releases
|
||||||
|
|
|
||||||
33
examples/user_middleware/Readme.md
Normal file
33
examples/user_middleware/Readme.md
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
# User Middleware
|
||||||
|
|
||||||
|
- Your middleware is defined in bb user sources.
|
||||||
|
- Middleware is a function in wrap-middleware style.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
Middleware should be a function in the form of:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
(defn my-middleware [handler]
|
||||||
|
(fn [request]
|
||||||
|
;; ...
|
||||||
|
(handler request)
|
||||||
|
;; ...
|
||||||
|
))
|
||||||
|
```
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
```shell
|
||||||
|
bb nrepl-server --middleware [my.middleware/println-middleware]
|
||||||
|
```
|
||||||
|
|
||||||
|
--middleware is a vector of fully qualified function symbols.
|
||||||
|
They are required to be located on the babashka classpath.
|
||||||
|
|
||||||
|
This will start babashka with a nrepl server with the middlware defined in `user_middleware/my_middleware/src/my/middleware.clj`.
|
||||||
|
|
||||||
|
You can now connect to the nrepl like usual.
|
||||||
|
|
||||||
|
It is possible to redefine the middleware function from within the running nrepl, because we keep a reference
|
||||||
|
to the sci-var of the middlware.
|
||||||
1
examples/user_middleware/my_middleware/deps.edn
Normal file
1
examples/user_middleware/my_middleware/deps.edn
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{:paths ["src"]}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
(ns my.middleware)
|
||||||
|
|
||||||
|
(defn println-middleware [handler]
|
||||||
|
(fn [request]
|
||||||
|
(println (:op (:msg request)))
|
||||||
|
(handler request)))
|
||||||
2
examples/user_middleware/my_project/bb.edn
Normal file
2
examples/user_middleware/my_project/bb.edn
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
{:deps
|
||||||
|
{my/middleware {:local/root "../my_middleware/"}}}
|
||||||
1
examples/user_middleware/my_project/hello_middleware.clj
Normal file
1
examples/user_middleware/my_project/hello_middleware.clj
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
(ns hello-middleware)
|
||||||
2
process
2
process
|
|
@ -1 +1 @@
|
||||||
Subproject commit 63bef86c76098366531ab973a79d04c51ae0856b
|
Subproject commit dadcff417675c84dcd32448e22e6270d1555af5d
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
:flaky :flaky}
|
:flaky :flaky}
|
||||||
:jvm-opts ["--enable-preview"]
|
:jvm-opts ["--enable-preview"]
|
||||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||||
[borkdude/edamame "1.3.20"]
|
[borkdude/edamame "1.3.22"]
|
||||||
[borkdude/graal.locking "0.0.2"]
|
[borkdude/graal.locking "0.0.2"]
|
||||||
[org.clojure/tools.cli "1.0.214"]
|
[org.clojure/tools.cli "1.0.214"]
|
||||||
[cheshire "5.11.0"]
|
[cheshire "5.11.0"]
|
||||||
|
|
@ -35,14 +35,14 @@
|
||||||
[com.github.clj-easy/graal-build-time "0.1.0"]
|
[com.github.clj-easy/graal-build-time "0.1.0"]
|
||||||
[rewrite-clj/rewrite-clj "1.1.46"]
|
[rewrite-clj/rewrite-clj "1.1.46"]
|
||||||
[insn/insn "0.5.2"]
|
[insn/insn "0.5.2"]
|
||||||
[org.babashka/cli "0.6.50"]
|
[org.babashka/cli "0.7.51"]
|
||||||
[org.babashka/http-client "0.1.8"]]
|
[org.babashka/http-client "0.2.9"]]
|
||||||
:plugins [[org.kipz/lein-meta-bom "0.1.1"]]
|
:plugins [[org.kipz/lein-meta-bom "0.1.1"]]
|
||||||
:metabom {:jar-name "metabom.jar"}
|
:metabom {:jar-name "metabom.jar"}
|
||||||
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
||||||
:dependencies [[org.clojure/data.xml "0.2.0-alpha8"]]}
|
:dependencies [[org.clojure/data.xml "0.2.0-alpha8"]]}
|
||||||
:feature/yaml {:source-paths ["feature-yaml"]
|
:feature/yaml {:source-paths ["feature-yaml"]
|
||||||
:dependencies [[clj-commons/clj-yaml "0.7.169"
|
:dependencies [[clj-commons/clj-yaml "1.0.26"
|
||||||
:exclusions [org.flatland/ordered]#_#_clj-commons/clj-yaml "0.7.110"]
|
:exclusions [org.flatland/ordered]#_#_clj-commons/clj-yaml "0.7.110"]
|
||||||
;; 1.15.10 cause native image bloat problem
|
;; 1.15.10 cause native image bloat problem
|
||||||
[org.flatland/ordered "1.5.9"]]}
|
[org.flatland/ordered "1.5.9"]]}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@
|
||||||
org.clojure/data.csv {:mvn/version "1.0.0"},
|
org.clojure/data.csv {:mvn/version "1.0.0"},
|
||||||
cheshire/cheshire {:mvn/version "5.11.0"}
|
cheshire/cheshire {:mvn/version "5.11.0"}
|
||||||
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
|
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
|
||||||
clj-commons/clj-yaml {:mvn/version "0.7.169"}
|
clj-commons/clj-yaml {:mvn/version "1.0.26"}
|
||||||
com.cognitect/transit-clj {:mvn/version "1.0.329"}
|
com.cognitect/transit-clj {:mvn/version "1.0.333"}
|
||||||
org.clojure/test.check {:mvn/version "1.1.1"}
|
org.clojure/test.check {:mvn/version "1.1.1"}
|
||||||
nrepl/bencode {:mvn/version "1.1.0"}
|
nrepl/bencode {:mvn/version "1.1.0"}
|
||||||
seancorfield/next.jdbc {:mvn/version "1.1.610"}
|
seancorfield/next.jdbc {:mvn/version "1.1.610"}
|
||||||
|
|
|
||||||
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit ae1679ceee89acb00d05744355f501ffaa3cbddb
|
Subproject commit 987910fb38fdd166865458c3fd4b468a22fb9992
|
||||||
|
|
@ -43,6 +43,7 @@ args=("-jar" "$BABASHKA_JAR"
|
||||||
"--verbose"
|
"--verbose"
|
||||||
"--no-fallback"
|
"--no-fallback"
|
||||||
"--native-image-info"
|
"--native-image-info"
|
||||||
|
"--install-exit-handlers"
|
||||||
# --trace-class-initialization=jdk.internal.net.http.common.DebugLogger,jdk.internal.net.http.websocket.WebSocketImpl,jdk.internal.net.http.common.Utils
|
# --trace-class-initialization=jdk.internal.net.http.common.DebugLogger,jdk.internal.net.http.websocket.WebSocketImpl,jdk.internal.net.http.common.Utils
|
||||||
"$BABASHKA_XMX"
|
"$BABASHKA_XMX"
|
||||||
"--enable-preview")
|
"--enable-preview")
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ call %GRAALVM_HOME%\bin\native-image.cmd ^
|
||||||
"--verbose" ^
|
"--verbose" ^
|
||||||
"--no-fallback" ^
|
"--no-fallback" ^
|
||||||
"--enable-preview" ^
|
"--enable-preview" ^
|
||||||
|
"--install-exit-handlers" ^
|
||||||
"%BABASHKA_XMX%"
|
"%BABASHKA_XMX%"
|
||||||
|
|
||||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,7 @@
|
||||||
java.net.http.WebSocket$Builder
|
java.net.http.WebSocket$Builder
|
||||||
java.net.http.WebSocket$Listener
|
java.net.http.WebSocket$Listener
|
||||||
java.security.cert.X509Certificate
|
java.security.cert.X509Certificate
|
||||||
|
java.security.cert.CertificateFactory
|
||||||
javax.crypto.Cipher
|
javax.crypto.Cipher
|
||||||
javax.crypto.Mac
|
javax.crypto.Mac
|
||||||
javax.crypto.SecretKey
|
javax.crypto.SecretKey
|
||||||
|
|
@ -317,7 +318,7 @@
|
||||||
java.lang.System
|
java.lang.System
|
||||||
java.lang.Throwable
|
java.lang.Throwable
|
||||||
java.lang.Thread$UncaughtExceptionHandler
|
java.lang.Thread$UncaughtExceptionHandler
|
||||||
;; java.lang.UnsupportedOperationException
|
java.lang.UnsupportedOperationException
|
||||||
java.lang.ref.WeakReference
|
java.lang.ref.WeakReference
|
||||||
java.lang.ref.ReferenceQueue
|
java.lang.ref.ReferenceQueue
|
||||||
java.lang.ref.Cleaner
|
java.lang.ref.Cleaner
|
||||||
|
|
@ -696,6 +697,8 @@
|
||||||
javax.crypto.SecretKey
|
javax.crypto.SecretKey
|
||||||
(instance? java.lang.Thread v)
|
(instance? java.lang.Thread v)
|
||||||
java.lang.Thread
|
java.lang.Thread
|
||||||
|
(instance? java.security.cert.X509Certificate v)
|
||||||
|
java.security.cert.X509Certificate
|
||||||
;; keep commas for merge friendliness
|
;; keep commas for merge friendliness
|
||||||
,,,)))
|
,,,)))
|
||||||
m (assoc m (list 'quote 'clojure.lang.Var) 'sci.lang.Var)
|
m (assoc m (list 'quote 'clojure.lang.Var) 'sci.lang.Var)
|
||||||
|
|
@ -764,7 +767,7 @@
|
||||||
Throwable java.lang.Throwable
|
Throwable java.lang.Throwable
|
||||||
VirtualMachineError java.lang.VirtualMachineError
|
VirtualMachineError java.lang.VirtualMachineError
|
||||||
ThreadDeath java.lang.ThreadDeath
|
ThreadDeath java.lang.ThreadDeath
|
||||||
;; UnsupportedOperationException java.lang.UnsupportedOperationException
|
UnsupportedOperationException java.lang.UnsupportedOperationException
|
||||||
})
|
})
|
||||||
|
|
||||||
(defn reflection-file-entries []
|
(defn reflection-file-entries []
|
||||||
|
|
|
||||||
|
|
@ -313,8 +313,11 @@ Use bb run --help to show this help output.
|
||||||
(defn start-socket-repl! [address ctx]
|
(defn start-socket-repl! [address ctx]
|
||||||
(socket-repl/start-repl! address ctx))
|
(socket-repl/start-repl! address ctx))
|
||||||
|
|
||||||
(defn start-nrepl! [address]
|
(defn start-nrepl! [user-middleware address]
|
||||||
(let [opts (nrepl-server/parse-opt address)]
|
(let [user-middleware (when-not (str/blank? user-middleware)
|
||||||
|
(read-string user-middleware))
|
||||||
|
opts (nrepl-server/parse-opt address)
|
||||||
|
opts (assoc opts :middleware user-middleware)]
|
||||||
(babashka.impl.nrepl-server/start-server! opts))
|
(babashka.impl.nrepl-server/start-server! opts))
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(println "For more info visit: https://book.babashka.org/#_nrepl"))
|
(println "For more info visit: https://book.babashka.org/#_nrepl"))
|
||||||
|
|
@ -645,6 +648,11 @@ Use bb run --help to show this help output.
|
||||||
(recur options
|
(recur options
|
||||||
(assoc opts-map
|
(assoc opts-map
|
||||||
:nrepl (or opt "1667"))))
|
:nrepl (or opt "1667"))))
|
||||||
|
("--middleware")
|
||||||
|
(let [options (next options)]
|
||||||
|
(recur (next options)
|
||||||
|
(assoc opts-map
|
||||||
|
:middleware (first options))))
|
||||||
("--eval", "-e")
|
("--eval", "-e")
|
||||||
(let [options (next options)
|
(let [options (next options)
|
||||||
opts-map (assoc opts-map :prn true)]
|
opts-map (assoc opts-map :prn true)]
|
||||||
|
|
@ -839,7 +847,7 @@ Use bb run --help to show this help output.
|
||||||
:main :uberscript :describe?
|
:main :uberscript :describe?
|
||||||
:jar :uberjar :clojure
|
:jar :uberjar :clojure
|
||||||
:doc :run :list-tasks
|
:doc :run :list-tasks
|
||||||
:print-deps :prepare]
|
:print-deps :prepare :middleware]
|
||||||
exec-fn :exec}
|
exec-fn :exec}
|
||||||
cli-opts
|
cli-opts
|
||||||
print-result? (:prn cli-opts)
|
print-result? (:prn cli-opts)
|
||||||
|
|
@ -1018,7 +1026,7 @@ Use bb run --help to show this help output.
|
||||||
describe?
|
describe?
|
||||||
[(print-describe) 0]
|
[(print-describe) 0]
|
||||||
repl [(repl/start-repl! sci-ctx) 0]
|
repl [(repl/start-repl! sci-ctx) 0]
|
||||||
nrepl [(start-nrepl! nrepl) 0]
|
nrepl [(start-nrepl! middleware nrepl) 0]
|
||||||
uberjar [nil 0]
|
uberjar [nil 0]
|
||||||
list-tasks [(tasks/list-tasks sci-ctx) 0]
|
list-tasks [(tasks/list-tasks sci-ctx) 0]
|
||||||
print-deps [(print-deps/print-deps (:print-deps-format cli-opts)) 0]
|
print-deps [(print-deps/print-deps (:print-deps-format cli-opts)) 0]
|
||||||
|
|
|
||||||
34
test-resources/certificate.crt
Normal file
34
test-resources/certificate.crt
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIF0zCCBLugAwIBAgIQByqysLNGGzf4RXfWDxaxzTANBgkqhkiG9w0BAQsFADA8
|
||||||
|
MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRwwGgYDVQQDExNBbWF6b24g
|
||||||
|
UlNBIDIwNDggTTAyMB4XDTIzMDIyMTAwMDAwMFoXDTIzMTAxNDIzNTk1OVowFjEU
|
||||||
|
MBIGA1UEAxMLY2xvanVyZS5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
|
||||||
|
AoIBAQC6JGRt221bAElnBPzSVOebsjPofEDQdLTfAr52LCQLCo/4x7cHsPTi9x4+
|
||||||
|
W3Pl7Fq0yrgimBhJHT34z7UeFqHEMnjsGxt7dLY0XJ87iikd8pz+v9xqXW8rrGaT
|
||||||
|
ykGx/85JFOGHJy+ZCparNYgUYN68IkaLe1QLb5w0GBcQa1U9JwpLqQVajrPDgD9Z
|
||||||
|
YRBJqgaFzJuRVsXo28rxHHFdNlP6PF2scMSFrAZEaex0bLXDxw/bHChzjypPODuO
|
||||||
|
ElsqxqI48Gsotqxe+iyP+Tu3B4GCHv2NKEFBYKiE+9UmNqQfXdVFvZFT+V2r4R9B
|
||||||
|
SMv3hpDNjmDcgpCVxmCI1sUttfQvAgMBAAGjggL1MIIC8TAfBgNVHSMEGDAWgBTA
|
||||||
|
MVLNWlDDgnx0cc7L6Zz5euuC4jAdBgNVHQ4EFgQUqkWGgRcK24T3gV3nNWwZ1EwQ
|
||||||
|
MPUwJwYDVR0RBCAwHoILY2xvanVyZS5vcmeCD3d3dy5jbG9qdXJlLm9yZzAOBgNV
|
||||||
|
HQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMDsGA1Ud
|
||||||
|
HwQ0MDIwMKAuoCyGKmh0dHA6Ly9jcmwucjJtMDIuYW1hem9udHJ1c3QuY29tL3Iy
|
||||||
|
bTAyLmNybDATBgNVHSAEDDAKMAgGBmeBDAECATB1BggrBgEFBQcBAQRpMGcwLQYI
|
||||||
|
KwYBBQUHMAGGIWh0dHA6Ly9vY3NwLnIybTAyLmFtYXpvbnRydXN0LmNvbTA2Bggr
|
||||||
|
BgEFBQcwAoYqaHR0cDovL2NydC5yMm0wMi5hbWF6b250cnVzdC5jb20vcjJtMDIu
|
||||||
|
Y2VyMAwGA1UdEwEB/wQCMAAwggF+BgorBgEEAdZ5AgQCBIIBbgSCAWoBaAB1AOg+
|
||||||
|
0No+9QY1MudXKLyJa8kD08vREWvs62nhd31tBr1uAAABhnTETgYAAAQDAEYwRAIg
|
||||||
|
IqyTlcuIQp6edqePX8mbZL42EgXfdTuFcBsoFdK9R5UCIEfKD8zISR0q08R2Zk6J
|
||||||
|
xnHAwBNsMXbebXu0ez3CjeDDAHcAs3N3B+GEUPhjhtYFqdwRCUp5LbFnDAuH3PAD
|
||||||
|
Dnk2pZoAAAGGdMROQQAABAMASDBGAiEAhVldSvw96LP/Qb48ZnHC0LqtsV77t/zd
|
||||||
|
7BCUNJY5bsACIQCENQ19xq5Yu7fWEB+qQQhjHlHD5yrocxqbdmMvdx9uggB2ALc+
|
||||||
|
+yTfnE26dfI5xbpY9Gxd/ELPep81xJ4dCYEl7bSZAAABhnTETg4AAAQDAEcwRQIh
|
||||||
|
APsLYOmzOz3qoDCqBULup/twLLmLLu5pK7R/zP1lyPP4AiBZ7PQzi4K2pD8Rfcv1
|
||||||
|
6Xm1oQwud8jmp1uQbnTCKHUPLjANBgkqhkiG9w0BAQsFAAOCAQEAdACtcuC2kFe0
|
||||||
|
sQU1m6nnjXdXpds25Xa+Rfbls2vyTqrmatFhSleOhzbkTOnWv/tNunHikttp3+DR
|
||||||
|
YOAbhJoUe4RVfuu1cQzL3kdc1q4MEmGgEl6V+jDO8657Ck1ld1ViGnqxKtncbV8b
|
||||||
|
k7hUOurO2saQhlzgylKyFL02Re+kXgw4x/U1n20MvvzHU6QCpU6KcAUeQfub3orQ
|
||||||
|
gEjmMxjOsnI38ZY8NX7guwhRiyFex3NOZ3avZxG6p8S5amXj8H6M8RBeQ07FVO3H
|
||||||
|
wj/WczPsGo6D8RG0nU4MiGCerMiY1oF9navINFTZptWiy/gVhR85XwQrKu+Pt+AM
|
||||||
|
47JAFeruig==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
|
@ -15,30 +15,31 @@
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(defn socket-command [expr expected & [log?]]
|
(defn socket-command-on-port [^long port]
|
||||||
(with-open [socket (java.net.Socket. "127.0.0.1" 1666)
|
(fn [expr expected & [log?]]
|
||||||
reader (io/reader socket)
|
(with-open [socket (java.net.Socket. "127.0.0.1" port)
|
||||||
sw (java.io.StringWriter.)
|
reader (io/reader socket)
|
||||||
writer (io/writer socket)]
|
sw (java.io.StringWriter.)
|
||||||
(binding [*out* writer]
|
writer (io/writer socket)]
|
||||||
(println (str expr "\n")))
|
(binding [*out* writer]
|
||||||
(loop []
|
(println (str expr "\n")))
|
||||||
(when-let [l (try (.readLine ^java.io.BufferedReader reader)
|
(loop []
|
||||||
(catch java.net.SocketException _ nil))]
|
(when-let [l (try (.readLine ^java.io.BufferedReader reader)
|
||||||
(when log?
|
(catch java.net.SocketException _ nil))]
|
||||||
(println "===" l))
|
(when log?
|
||||||
(binding [*out* sw]
|
(println "===" l))
|
||||||
(println l))
|
(binding [*out* sw]
|
||||||
(let [s (str sw)]
|
(println l))
|
||||||
;; (prn :s s :expected expected (str/includes? s expected))
|
(let [s (str sw)]
|
||||||
(if (if (fn? expected)
|
;; (prn :s s :expected expected (str/includes? s expected))
|
||||||
(expected s)
|
(if (if (fn? expected)
|
||||||
(str/includes? s expected))
|
(expected s)
|
||||||
(is true)
|
(str/includes? s expected))
|
||||||
(recur)))))
|
(is true)
|
||||||
(binding [*out* writer]
|
(recur)))))
|
||||||
(println ":repl/quit\n"))
|
(binding [*out* writer]
|
||||||
:success))
|
(println ":repl/quit\n"))
|
||||||
|
:success)))
|
||||||
|
|
||||||
(def server-process (volatile! nil))
|
(def server-process (volatile! nil))
|
||||||
|
|
||||||
|
|
@ -46,87 +47,90 @@
|
||||||
|
|
||||||
(deftest ^:flaky socket-repl-test
|
(deftest ^:flaky socket-repl-test
|
||||||
(when exec?
|
(when exec?
|
||||||
(try
|
(let [socket-command (socket-command-on-port 1666)]
|
||||||
(if tu/jvm?
|
(try
|
||||||
(let [ctx (init {:namespaces main/namespaces
|
|
||||||
:features #{:bb}})]
|
|
||||||
(ctx-store/reset-ctx! ctx)
|
|
||||||
(start-repl! "0.0.0.0:1666" ctx))
|
|
||||||
(do (vreset! server-process
|
|
||||||
(p/process ["./bb" "socket-repl" "localhost:1666"]))
|
|
||||||
(w/wait-for-port "localhost" 1666)))
|
|
||||||
(Thread/sleep 50)
|
|
||||||
(is (socket-command "(+ 1 2 3)" "user=> 6"))
|
|
||||||
(testing "&env"
|
|
||||||
(socket-command "(defmacro bindings [] (mapv #(list 'quote %) (keys &env)))" "bindings")
|
|
||||||
(socket-command "(defn bar [x y z] (bindings))" "bar")
|
|
||||||
(is (socket-command "(bar 1 2 3)" "[x y z]")))
|
|
||||||
(testing "reader conditionals"
|
|
||||||
(is (socket-command "#?(:bb 1337 :clj 8888)" "1337")))
|
|
||||||
(testing "*1, *2, *3, *e"
|
|
||||||
(is (socket-command "1\n*1" "1")))
|
|
||||||
(testing "*ns*"
|
|
||||||
(is (socket-command "(ns foo.bar) (ns-name *ns*)" "foo.bar")))
|
|
||||||
(testing "set dyn vars"
|
|
||||||
(is (socket-command "[(set! *warn-on-reflection* true) (set! *unchecked-math* true)]" "[true true]")))
|
|
||||||
(finally
|
|
||||||
(if tu/jvm?
|
(if tu/jvm?
|
||||||
(do (stop-repl!)
|
(let [ctx (init {:namespaces main/namespaces
|
||||||
(ctx-store/reset-ctx! nil)
|
:features #{:bb}})]
|
||||||
(Thread/sleep 100))
|
(ctx-store/reset-ctx! ctx)
|
||||||
(p/destroy-tree @server-process))))))
|
(start-repl! "0.0.0.0:1666" ctx))
|
||||||
|
(do (vreset! server-process
|
||||||
|
(p/process ["./bb" "socket-repl" "localhost:1666"]))
|
||||||
|
(w/wait-for-port "localhost" 1666)))
|
||||||
|
(Thread/sleep 50)
|
||||||
|
(is (socket-command "(+ 1 2 3)" "user=> 6"))
|
||||||
|
(testing "&env"
|
||||||
|
(socket-command "(defmacro bindings [] (mapv #(list 'quote %) (keys &env)))" "bindings")
|
||||||
|
(socket-command "(defn bar [x y z] (bindings))" "bar")
|
||||||
|
(is (socket-command "(bar 1 2 3)" "[x y z]")))
|
||||||
|
(testing "reader conditionals"
|
||||||
|
(is (socket-command "#?(:bb 1337 :clj 8888)" "1337")))
|
||||||
|
(testing "*1, *2, *3, *e"
|
||||||
|
(is (socket-command "1\n*1" "1")))
|
||||||
|
(testing "*ns*"
|
||||||
|
(is (socket-command "(ns foo.bar) (ns-name *ns*)" "foo.bar")))
|
||||||
|
(testing "set dyn vars"
|
||||||
|
(is (socket-command "[(set! *warn-on-reflection* true) (set! *unchecked-math* true)]" "[true true]")))
|
||||||
|
(finally
|
||||||
|
(if tu/jvm?
|
||||||
|
(do (stop-repl!)
|
||||||
|
(ctx-store/reset-ctx! nil)
|
||||||
|
(Thread/sleep 100))
|
||||||
|
(p/destroy-tree @server-process)))))))
|
||||||
|
|
||||||
(deftest ^:flaky socket-repl-opts-test
|
(deftest ^:flaky socket-repl-opts-test
|
||||||
(when exec?
|
(when exec?
|
||||||
(try
|
(let [socket-command (socket-command-on-port 1667)]
|
||||||
(if tu/jvm?
|
(try
|
||||||
(let [ctx (init {:bindings {'*command-line-args*
|
(if tu/jvm?
|
||||||
["a" "b" "c"]}
|
(let [ctx (init {:bindings {'*command-line-args*
|
||||||
:env (atom {})
|
["a" "b" "c"]}
|
||||||
:namespaces {'clojure.core.server clojure-core-server-namespace}
|
:env (atom {})
|
||||||
:features #{:bb}})]
|
:namespaces {'clojure.core.server clojure-core-server-namespace}
|
||||||
(ctx-store/reset-ctx! ctx)
|
:features #{:bb}})]
|
||||||
(start-repl! "{:address \"localhost\" :accept clojure.core.server/repl :port 1666}"
|
(ctx-store/reset-ctx! ctx)
|
||||||
ctx))
|
(start-repl! "{:address \"localhost\" :accept clojure.core.server/repl :port 1667}"
|
||||||
(do (vreset! server-process
|
ctx))
|
||||||
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/repl :port 1666}"]))
|
(do (vreset! server-process
|
||||||
(w/wait-for-port "localhost" 1666)))
|
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/repl :port 1667}"]))
|
||||||
(Thread/sleep 50)
|
(w/wait-for-port "localhost" 1667)))
|
||||||
(is (socket-command "(+ 1 2 3)" "user=> 6"))
|
(Thread/sleep 50)
|
||||||
(finally
|
(is (socket-command "(+ 1 2 3)" "user=> 6"))
|
||||||
(if tu/jvm?
|
(finally
|
||||||
(do (stop-repl!)
|
(if tu/jvm?
|
||||||
(ctx-store/reset-ctx! nil)
|
(do (stop-repl!)
|
||||||
(Thread/sleep 100))
|
(ctx-store/reset-ctx! nil)
|
||||||
(p/destroy-tree @server-process))))))
|
(Thread/sleep 100))
|
||||||
|
(p/destroy-tree @server-process)))))))
|
||||||
|
|
||||||
(deftest ^:flaky socket-prepl-test
|
(deftest ^:flaky socket-prepl-test
|
||||||
(when exec?
|
(when exec?
|
||||||
(try
|
(let [socket-command (socket-command-on-port 1668)]
|
||||||
(if tu/jvm?
|
(try
|
||||||
(let [ctx (init {:bindings {'*command-line-args*
|
(if tu/jvm?
|
||||||
["a" "b" "c"]}
|
(let [ctx (init {:bindings {'*command-line-args*
|
||||||
:env (atom {})
|
["a" "b" "c"]}
|
||||||
:namespaces {'clojure.core.server clojure-core-server-namespace}
|
:env (atom {})
|
||||||
:features #{:bb}})]
|
:namespaces {'clojure.core.server clojure-core-server-namespace}
|
||||||
(ctx-store/reset-ctx! ctx)
|
:features #{:bb}})]
|
||||||
(start-repl! "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1666}"
|
(ctx-store/reset-ctx! ctx)
|
||||||
ctx))
|
(start-repl! "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1668}"
|
||||||
(do (vreset! server-process
|
ctx))
|
||||||
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1666}"]))
|
(do (vreset! server-process
|
||||||
(w/wait-for-port "localhost" 1666)))
|
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1668}"]))
|
||||||
(Thread/sleep 50)
|
(w/wait-for-port "localhost" 1668)))
|
||||||
(is (socket-command "(+ 1 2 3)" (fn [s]
|
(Thread/sleep 50)
|
||||||
(let [m (edn/read-string s)]
|
(is (socket-command "(+ 1 2 3)" (fn [s]
|
||||||
(and (= "6" (:val m))
|
(let [m (edn/read-string s)]
|
||||||
(= "user" (:ns m))
|
(and (= "6" (:val m))
|
||||||
(= "(+ 1 2 3)" (:form m)))))))
|
(= "user" (:ns m))
|
||||||
(finally
|
(= "(+ 1 2 3)" (:form m)))))))
|
||||||
(if tu/jvm?
|
(finally
|
||||||
(do (stop-repl!)
|
(if tu/jvm?
|
||||||
(ctx-store/reset-ctx! nil)
|
(do (stop-repl!)
|
||||||
(Thread/sleep 100))
|
(ctx-store/reset-ctx! nil)
|
||||||
(p/destroy-tree @server-process))))))
|
(Thread/sleep 100))
|
||||||
|
(p/destroy-tree @server-process)))))))
|
||||||
|
|
||||||
;;;; Scratch
|
;;;; Scratch
|
||||||
|
|
||||||
|
|
@ -141,5 +145,5 @@
|
||||||
'*command-line-args*
|
'*command-line-args*
|
||||||
["a" "b" "c"]}
|
["a" "b" "c"]}
|
||||||
:env (atom {})})
|
:env (atom {})})
|
||||||
(socket-command "(+ 1 2 3)" "6")
|
((socket-command-on-port 1666) "(+ 1 2 3)" "6")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,17 @@
|
||||||
(is (true? (bb nil "(= (first {1 2})
|
(is (true? (bb nil "(= (first {1 2})
|
||||||
(clojure.lang.MapEntry. 1 2)
|
(clojure.lang.MapEntry. 1 2)
|
||||||
(clojure.lang.MapEntry/create 1 2))"))))
|
(clojure.lang.MapEntry/create 1 2))"))))
|
||||||
|
|
||||||
|
(deftest X509Certificate-test
|
||||||
|
(is (true? (bb nil "(import java.security.cert.X509Certificate)
|
||||||
|
(import java.security.cert.CertificateFactory)
|
||||||
|
(require '[clojure.java.io :as io])
|
||||||
|
(defn x509-certificate
|
||||||
|
^X509Certificate
|
||||||
|
[f]
|
||||||
|
(let [input (io/input-stream f)
|
||||||
|
factory (CertificateFactory/getInstance \"X.509\")]
|
||||||
|
(.generateCertificate factory input)))
|
||||||
|
(def cert (x509-certificate (io/file \"test-resources/certificate.crt\")))
|
||||||
|
(some? (.getSubjectX500Principal cert))
|
||||||
|
"))))
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
(deftest parse-opts-test
|
(deftest parse-opts-test
|
||||||
(is (= "1667"
|
(is (= "1667"
|
||||||
(:nrepl (parse-opts ["--nrepl-server"]))))
|
(:nrepl (parse-opts ["--nrepl-server"]))))
|
||||||
|
(is (= "[foo]"
|
||||||
|
(:middleware (parse-opts ["--middleware" "[foo]"]))))
|
||||||
(is (= "1666"
|
(is (= "1666"
|
||||||
(:socket-repl (parse-opts ["--socket-repl"]))))
|
(:socket-repl (parse-opts ["--socket-repl"]))))
|
||||||
(is (= {:nrepl "1667", :classpath "src"}
|
(is (= {:nrepl "1667", :classpath "src"}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue