From 512a6f2220a0e54ab585ead1dec2b10995f637f9 Mon Sep 17 00:00:00 2001 From: rng-dynamics <73444470+rng-dynamics@users.noreply.github.com> Date: Thu, 20 May 2021 22:49:58 +0200 Subject: [PATCH 01/83] feat: print data of uncaught ExceptionInfo to output (#854) * feat: print data of uncaught ExceptionInfo to output * println -> prn, add tests --- src/babashka/impl/error_handler.clj | 3 +++ test/babashka/error_test.clj | 30 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/babashka/impl/error_handler.clj b/src/babashka/impl/error_handler.clj index d0ad4750..e941c8ef 100644 --- a/src/babashka/impl/error_handler.clj +++ b/src/babashka/impl/error_handler.clj @@ -100,6 +100,9 @@ (.. e getClass getName))) (when-let [m (.getMessage e)] (println (str "Message: " m))) + (when-let [d (ex-data (.getCause e))] + (print (str "Data: ")) + (prn d)) (let [{:keys [:file :line :column]} d] (when line (println (str "Location: " diff --git a/test/babashka/error_test.clj b/test/babashka/error_test.clj index 857ca787..25914e35 100644 --- a/test/babashka/error_test.clj +++ b/test/babashka/error_test.clj @@ -169,3 +169,33 @@ user/quux - :1:15 user/quux - :1:1 user/bar - :1:69 user - :1:91")))) + +(deftest print-exception-data-test + (testing "output of uncaught ExceptionInfo" + (let [output (try (tu/bb nil "(let [d {:zero 0 :one 1}] (throw (ex-info \"some msg\" d)))") + (catch Exception e (ex-message e)))] + (multiline-equals output + "----- Error -------------------------------------------------------------------- +Type: clojure.lang.ExceptionInfo +Message: some msg +Data: {:zero 0, :one 1} +Location: :1:27 + +----- Context ------------------------------------------------------------------ +1: (let [d {:zero 0 :one 1}] (throw (ex-info \"some msg\" d))) + ^--- some msg + +----- Locals ------------------------------------------------------------------- +d: {:zero 0, :one 1}"))) + (testing "output of ordinary Exception" + (let [output (try (tu/bb nil "(throw (Exception. \"some msg\"))") + (catch Exception e (ex-message e)))] + (multiline-equals output + "----- Error -------------------------------------------------------------------- +Type: java.lang.Exception +Message: some msg +Location: :1:1 + +----- Context ------------------------------------------------------------------ +1: (throw (Exception. \"some msg\")) + ^--- some msg")))) From 20cc3b4cddbeb7529ae2a156c143e159ca44b38b Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 21 May 2021 11:52:38 -0300 Subject: [PATCH 02/83] Use shasum instead of sha256sum [skip ci] (#861) sha256sum is not available in macOS by default. See: https://github.com/ESGF/esg-search/issues/84#issuecomment-213694850 However, shasum seems to be avaialble, so use that instead. --- install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install b/install index 14520a2f..41d7cfbc 100755 --- a/install +++ b/install @@ -118,9 +118,9 @@ rm -rf "$filename" rm -rf "bb" curl -o "$filename" -sL "$download_url" if [[ -n "$checksum" ]]; then - if ! echo "$checksum $filename" | sha256sum --check --status; then + if ! echo "$checksum *$filename" | shasum -a 256 --check --status; then >&2 echo "Failed checksum on $filename" - >&2 echo "Got: $(sha256sum "$filename" | cut -d' ' -f1)" + >&2 echo "Got: $(shasum -a 256 "$filename" | cut -d' ' -f1)" >&2 echo "Expected: $checksum" exit 1 fi From 4a5972f15e705eeed63e299ca05c1525afdd6231 Mon Sep 17 00:00:00 2001 From: Jakub Holy Date: Fri, 21 May 2021 19:35:51 +0200 Subject: [PATCH 03/83] projects: + oidc-client (#862) [skip ci] --- doc/projects.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/projects.md b/doc/projects.md index 4194eef8..fd535537 100644 --- a/doc/projects.md +++ b/doc/projects.md @@ -60,6 +60,7 @@ The following libraries and projects are known to work with babashka. - [interdep](#interdep) - [sha-words](#sha-words) - [adam-james-v/scripts](#adam-james-vscripts) + - [oidc-client](#oidc-client) Also keep an eye on the [news](news.md) page for new projects, gists and other developments around babashka. @@ -649,3 +650,9 @@ A clojure program to turn a sha hash into list of nouns in a predictable jar. ### [adam-james-v/scripts](https://github.com/adam-james-v/scripts) A collection of useful scripts. Mainly written with Clojure/babashka + +### [oidc-client](https://gist.github.com/holyjak/ad4e1e9b863f8ed57ef0cb6ac6b30494) + +Tired of being forced to use the browser every time you need to refresh an OIDC token to authenticate with a backend service? Finally there is a CLI tool for that - the babashka and Docker powered oidc_client.clj. + +Upon first invocation it opens up a browser for the OIDC provider login, thereafter it caches the refresh token and uses it as long as it remains valid. From 5890238666be1f64ed9113c28e2b00b6e329ef69 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 21 May 2021 20:23:39 +0200 Subject: [PATCH 04/83] deps.clj --- deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.clj b/deps.clj index f59e735a..480f6955 160000 --- a/deps.clj +++ b/deps.clj @@ -1 +1 @@ -Subproject commit f59e735a585d73e9f800a7e824e2afa550092caf +Subproject commit 480f6955936cf44b9fb9d0d73ece3bc6f6001053 From 6bcc0e4a3fe4732d561a88f51047609afc45c02c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 22 May 2021 14:00:54 +0200 Subject: [PATCH 05/83] deps.clj --- deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.clj b/deps.clj index 480f6955..3e50b7b8 160000 --- a/deps.clj +++ b/deps.clj @@ -1 +1 @@ -Subproject commit 480f6955936cf44b9fb9d0d73ece3bc6f6001053 +Subproject commit 3e50b7b8f04a1463bec31a973d08e76077f26e4f From 3eafacac2b76f5f85424930dba713446f144657e Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 25 May 2021 15:43:56 +0200 Subject: [PATCH 06/83] sci: set! for CLJS --- sci | 2 +- src/babashka/impl/tasks.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sci b/sci index 4de7c780..caf23378 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 4de7c78024bfdb5c52e273be372144d46228939a +Subproject commit caf2337833fb265190a1cd332804e2999db13dc6 diff --git a/src/babashka/impl/tasks.clj b/src/babashka/impl/tasks.clj index a21a18c8..ee3fb3ad 100644 --- a/src/babashka/impl/tasks.clj +++ b/src/babashka/impl/tasks.clj @@ -20,7 +20,7 @@ (def log-level (sci/new-dynamic-var '*-log-level* default-log-level {:ns sci-ns})) ;; (def task-name (sci/new-dynamic-var '*-task-name* nil {:ns sci-ns})) (def task (sci/new-dynamic-var '*task* nil {:ns sci-ns})) -(def current-task (sci/new-dynamic-var 'current-task (fn [] @task) {:ns sci-ns})) +(def current-task (sci/new-var 'current-task (fn [] @task) {:ns sci-ns})) (def state (sci/new-var 'state (atom {}) {:ns sci-ns})) (defn log-info [& strs] From 4b4ada961774e84a9a9b1474b76048802379d443 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 25 May 2021 13:52:30 -0300 Subject: [PATCH 07/83] Improve script/setup-musl (#867) --- script/setup-musl | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/script/setup-musl b/script/setup-musl index bc5d90ed..118c98ec 100755 --- a/script/setup-musl +++ b/script/setup-musl @@ -47,16 +47,10 @@ arch=${BABASHKA_ARCH:-"x86_64"} echo "ARCH: $arch" cd "zlib-${ZLIB_VERSION}" -CC=musl-gcc ./configure --static --prefix=/usr/lib/$arch-linux-musl/ +CC=musl-gcc ./configure --static --prefix="/usr/local" make CC=musl-gcc -sudo make install -export CC=gcc +make install cd .. -# depending on GCC version, we will have different directories here. -# for example, for GCC 6.3.0 we will have: -# - /usr/lib/gcc/x86_64-linux-gnu/6 -# - /usr/lib/gcc/x86_64-linux-gnu/6.3.0 -for dest_dir in /usr/lib/gcc/$arch-linux-gnu/*; do - sudo cp -f /usr/lib/$arch-linux-musl/lib/libz.a "$dest_dir" -done +# Install libz.a in the correct place so ldd can find it +install -Dm644 "/usr/local/lib/libz.a" "/usr/lib/$arch-linux-musl/libz.a" From 17f35b4d482d014181b36e4b79b57ed7833d2ab2 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 26 May 2021 17:37:40 +0200 Subject: [PATCH 08/83] sci and tweak aot --- project.clj | 2 +- sci | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project.clj b/project.clj index 56ae74f0..4170489b 100644 --- a/project.clj +++ b/project.clj @@ -80,7 +80,7 @@ "-Dclojure.spec.skip-macros=true" "-Dborkdude.dynaload.aot=true"] :main babashka.main - :aot :all} + :aot [babashka.main]} :reflection {:main babashka.impl.classes/generate-reflection-file}} :aliases {"bb" ["with-profile" "test" "run" "-m" "babashka.main"]} :deploy-repositories [["clojars" {:url "https://clojars.org/repo" diff --git a/sci b/sci index caf23378..5e353826 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit caf2337833fb265190a1cd332804e2999db13dc6 +Subproject commit 5e3538264ad3198dbbd840a5a2ea5ef7ae5103cd From ec479f049a20c6154b351f4053fe359ac9cdd6eb Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 27 May 2021 09:31:35 +0200 Subject: [PATCH 09/83] Example: xml-zip [skip ci] --- examples/README.md | 2 ++ examples/pom_version_get_xml_zip.clj | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 examples/pom_version_get_xml_zip.clj diff --git a/examples/README.md b/examples/README.md index 7211218c..37553d7a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -300,6 +300,8 @@ $ examples/which.clj rg A script to retrieve the version from a `pom.xml` file. See [pom_version_get.clj](pom_version_get.clj). Written by [@wilkerlucio](https://github.com/wilkerlucio). +See [pom_version_get_xml_zip.clj](pom_version_get_xml_zip.clj) for how to do the same using zippers. + Also see [pom_version_set.clj](pom_version_set.clj) to set the pom version. ## Whatsapp frequencies diff --git a/examples/pom_version_get_xml_zip.clj b/examples/pom_version_get_xml_zip.clj new file mode 100644 index 00000000..9caa1a9e --- /dev/null +++ b/examples/pom_version_get_xml_zip.clj @@ -0,0 +1,15 @@ +(require '[babashka.deps :as deps]) + +(deps/add-deps '{:deps {org.clojure/data.zip {:mvn/version "RELEASE"}}}) + +(require '[clojure.data.xml :as xml] + '[clojure.data.zip.xml :as xmlz] + '[clojure.zip :as zip]) + +(def xml "1.0.0") + +(-> xml + xml/parse-str + zip/xml-zip + (xmlz/xml1-> :pom :version zip/down zip/node)) +;; => 1.0.0 From 48a9ec6c0d83ff1d941f732d6fe657f9c1e6d970 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 27 May 2021 17:35:55 +0200 Subject: [PATCH 10/83] Install script [skip ci] --- install | 4 ---- sci | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/install b/install index 41d7cfbc..e6bb2f2b 100755 --- a/install +++ b/install @@ -29,10 +29,6 @@ print_help() { exit 1 } -if [[ $# -eq 1 ]]; then - install_dir=${1:-} -fi - while [[ $# -gt 0 ]] do key="$1" diff --git a/sci b/sci index 5e353826..8d9d10b3 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 5e3538264ad3198dbbd840a5a2ea5ef7ae5103cd +Subproject commit 8d9d10b355cbd7ea1919d8935891c94e76f19485 From 7a3c30ab3fbc67d86e418cb554599f5a9ed0432a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 09:28:14 +0200 Subject: [PATCH 11/83] babashka.fs [skip ci] --- fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs b/fs index 05d39293..1beb91cd 160000 --- a/fs +++ b/fs @@ -1 +1 @@ -Subproject commit 05d392933a4e6fe0e0c3fa002c1bdeeccc995801 +Subproject commit 1beb91cd5f352d1e3a914c94e7ec25a2644b07e5 From b9524e5d6e405eec147fa61c28f0ccdd78d4dfb3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 11:30:16 +0200 Subject: [PATCH 12/83] sci: case improvements --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 8d9d10b3..5c02094c 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 8d9d10b355cbd7ea1919d8935891c94e76f19485 +Subproject commit 5c02094c223b6bb1b3ae2baefd57e9530e26960a From 1fe1e46e71a157c01182e9408eefaf67726daa1d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 11:44:20 +0200 Subject: [PATCH 13/83] sci: minor improvements --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 5c02094c..6ec16e4e 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 5c02094c223b6bb1b3ae2baefd57e9530e26960a +Subproject commit 6ec16e4e52943be9fcb5aaff19c17e014fcebbcc From 745e2b0848b4fe1fb665497d81b31a4a0501c99c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 11:50:48 +0200 Subject: [PATCH 14/83] sci minor [skip ci] --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 6ec16e4e..1b091620 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 6ec16e4e52943be9fcb5aaff19c17e014fcebbcc +Subproject commit 1b0916205fd901bd7a9be7561e32bfd54607fffe From 1c1d4b531f29e9684464d89b5297ccf074b65757 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 13:33:11 +0200 Subject: [PATCH 15/83] Install script: default download dir to TMPDIR [skip ci] --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index e6bb2f2b..7dedd80d 100755 --- a/install +++ b/install @@ -7,7 +7,7 @@ checksum="" static_binary="false" default_install_dir="/usr/local/bin" install_dir="$default_install_dir" -default_download_dir="/tmp" +default_download_dir=${TMPDIR:-"/tmp"} download_dir="$default_download_dir" print_help() { From e955926ee927431ceaa1859968b85be5b6290442 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 28 May 2021 12:07:52 -0300 Subject: [PATCH 16/83] Improvements to install script [skip ci] (#870) - Use `mktemp -d` to generate a temporary directory, only if user doesn't use `--download-dir` - Clean-up the temporary directory using `trap`. Remove other `rm` calls from code since they're not necessary anymore - Run download in a subshell, so after finishing it the script is still on the directory where the user ran the script. Fix `./install --dir .` usage - Fix backup of old Babashka install --- install | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/install b/install index 7dedd80d..2ab2d3ea 100755 --- a/install +++ b/install @@ -7,8 +7,7 @@ checksum="" static_binary="false" default_install_dir="/usr/local/bin" install_dir="$default_install_dir" -default_download_dir=${TMPDIR:-"/tmp"} -download_dir="$default_download_dir" +download_dir="" print_help() { echo "Installs latest (or specific) version of babashka. Installation directory defaults to /usr/local/bin." @@ -18,7 +17,7 @@ print_help() { echo -e echo "Defaults:" echo " * Installation directory: ${default_install_dir}" - echo " * Download directory: ${default_download_dir}" + echo " * Download directory: temporary" if [[ -z "$checksum" ]]; then echo " * Checksum: no" else @@ -64,6 +63,11 @@ do esac done +if [[ -z "$download_dir" ]]; then + download_dir="$(mktemp -d)" + trap 'rm -rf "$download_dir"' EXIT +fi + if [[ "$checksum" != "" ]] && [[ "$version" == "" ]]; then >&2 echo "Options --checksum and --version should be provided together!" exit 1 @@ -81,7 +85,7 @@ esac case "$(uname -m)" in aarch64) arch=aarch64;; esac -arch=${arch:-amd64} +arch="${arch:-amd64}" # Ugly ugly conversion of version to a comparable number IFS='.' read -ra VER <<< "$version" @@ -106,29 +110,30 @@ else fi download_url="https://github.com/babashka/babashka/releases/download/v$version/$filename" -mkdir -p "$download_dir" -cd "$download_dir" -echo -e "Downloading $download_url to $download_dir" +# Running this part in a subshell so when it finishes we go back to the previous directory +mkdir -p "$download_dir" && ( + cd "$download_dir" + echo -e "Downloading $download_url to $download_dir" -rm -rf "$filename" -rm -rf "bb" -curl -o "$filename" -sL "$download_url" -if [[ -n "$checksum" ]]; then - if ! echo "$checksum *$filename" | shasum -a 256 --check --status; then - >&2 echo "Failed checksum on $filename" - >&2 echo "Got: $(shasum -a 256 "$filename" | cut -d' ' -f1)" - >&2 echo "Expected: $checksum" - exit 1 + curl -o "$filename" -sL "$download_url" + if [[ -n "$checksum" ]]; then + if ! echo "$checksum *$filename" | shasum -a 256 --check --status; then + >&2 echo "Failed checksum on $filename" + >&2 echo "Got: $(shasum -a 256 "$filename" | cut -d' ' -f1)" + >&2 echo "Expected: $checksum" + exit 1 + fi fi -fi -$util "$filename" -rm "$filename" + $util "$filename" + rm -f "$filename" +) if [[ "$download_dir" != "$install_dir" ]] then mkdir -p "$install_dir" if [ -f "$install_dir/bb" ]; then echo "Moving $install_dir/bb to $install_dir/bb.old" + mv -f "$install_dir/bb" "$install_dir/bb.old" fi mv -f "$download_dir/bb" "$install_dir/bb" fi From f5deafffb87bfbeedaa6490b87ecba3b99349e7e Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 17:15:35 +0200 Subject: [PATCH 17/83] sci: try / catch --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 1b091620..eff9737f 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 1b0916205fd901bd7a9be7561e32bfd54607fffe +Subproject commit eff9737ff1a772f5a9a39e2a8a85e34199851eec From fa410a7b5e805fde5eabba7c125d6a5aa241b872 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 28 May 2021 19:03:02 +0200 Subject: [PATCH 18/83] sci: enhancement for throw --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index eff9737f..680037c0 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit eff9737ff1a772f5a9a39e2a8a85e34199851eec +Subproject commit 680037c0758fd62af3e5c7e78d341cf195642dd6 From 0a3149ae8ad3087878508ea92bcc549d52c0b298 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 28 May 2021 18:43:31 -0300 Subject: [PATCH 19/83] Do not exit when --static is called on non-Linux [skip ci] (#871) While creating [this gist](https://gist.github.com/thiagokokada/115b2588ff65a48d54b8832488801c92) I realized that exiting if the --static flag is passed on non-Linux systems just make more difficult to handle those cases. Instead, let's just print a message informing the user of their mistake, and keep running the script with the correct filename. --- install | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/install b/install index 2ab2d3ea..e21e5a11 100755 --- a/install +++ b/install @@ -78,14 +78,14 @@ if [[ "$version" == "" ]]; then fi case "$(uname -s)" in - Linux*) platform=linux;; - Darwin*) platform=macos;; + Linux*) platform=linux;; + Darwin*) platform=macos;; esac case "$(uname -m)" in - aarch64) arch=aarch64;; + aarch64) arch=aarch64;; + *) arch=amd64;; esac -arch="${arch:-amd64}" # Ugly ugly conversion of version to a comparable number IFS='.' read -ra VER <<< "$version" @@ -99,15 +99,16 @@ else util="$(which tar) -zxf" fi -if [[ "$static_binary" == "true" ]]; then - if [[ "$platform" != "linux" ]]; then - >&2 echo "Static binaries are only available in Linux platform!" - exit 1 - fi - filename="babashka-$version-$platform-$arch-static."$ext -else - filename="babashka-$version-$platform-$arch."$ext -fi +case "$platform-$static_binary" in + linux-true) filename="babashka-$version-$platform-$arch-static."$ext + ;; + *-true) >&2 echo "Static binaries are only available in Linux platform! Using the non-static one..." + filename="babashka-$version-$platform-$arch."$ext + ;; + *) filename="babashka-$version-$platform-$arch."$ext + ;; +esac + download_url="https://github.com/babashka/babashka/releases/download/v$version/$filename" # Running this part in a subshell so when it finishes we go back to the previous directory From b731cf7f109f7d474a95351d175339e1399d3b3a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 29 May 2021 11:06:59 +0200 Subject: [PATCH 20/83] sci: lazy-seq enhancement --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 680037c0..a06c7d1c 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 680037c0758fd62af3e5c7e78d341cf195642dd6 +Subproject commit a06c7d1c0afdb68a18038619f31ce8bed598284e From 9347bfd3d399da7b0eb102554c5054af33a7d2db Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 29 May 2021 13:47:14 +0200 Subject: [PATCH 21/83] sci: new/constructor enhancement --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index a06c7d1c..a8505dd4 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit a06c7d1c0afdb68a18038619f31ce8bed598284e +Subproject commit a8505dd4ee0b5cc7e6f6215f1bbc136c6d4ae7ee From 94fc8298e68181172df9d1a681491ec9f15bff98 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 11:27:11 +0200 Subject: [PATCH 22/83] [#865] Use print-meta when emitting tasks --- src/babashka/impl/tasks.clj | 144 +++++++++++++++------------------- test/babashka/bb_edn_test.clj | 11 ++- 2 files changed, 75 insertions(+), 80 deletions(-) diff --git a/src/babashka/impl/tasks.clj b/src/babashka/impl/tasks.clj index ee3fb3ad..ab6c24b1 100644 --- a/src/babashka/impl/tasks.clj +++ b/src/babashka/impl/tasks.clj @@ -31,15 +31,6 @@ (binding [*out* *err*] (println (format "[bb %s]" (:name @task)) (str/join " " strs)))))) -#_(defn log-error [& strs] - (let [log-level @log-level] - (when (or - ;; log error also in case of info level - (identical? :info log-level) - (identical? :error log-level)) - (binding [*out* *err*] - (println (format "[bb %s]" (:name @task)) (str/join " " strs)))))) - (defn- handle-non-zero [proc opts] (when proc (when-let [proc (deref proc)] @@ -268,7 +259,7 @@ (if (seq requires) (format "(:require %s)" (str/join " " requires)) "") - (str init) + (pr-str init) prog)) (defn target-order @@ -303,75 +294,70 @@ enter (:enter tasks) leave (:leave tasks) task (get tasks task-name)] - (if task - (let [m? (map? task) - requires (get tasks :requires) - init (get tasks :init) - prog (if-let [depends (when m? (:depends task))] - (let [[targets error] - (try [(target-order tasks task-name)] - (catch clojure.lang.ExceptionInfo e - [nil (ex-message e)])) - #_#_dependees (tasks->dependees targets tasks) - task-map (cond-> {} - enter (assoc :enter enter) - leave (assoc :leave leave) - parallel? (assoc :parallel parallel?))] - (if error - [(binding [*out* *err*] - (println error)) 1] - (loop [prog "" - targets (seq targets) - done [] - extra-paths [] - extra-deps nil - requires requires] - (let [t (first targets) - targets (next targets) - #_#_ depends-on-t (get dependees t) - task-map (cond-> - (assoc task-map - :name t - #_#_:started done) - #_#_targets (assoc :pending (vec targets)) - #_#_depends-on-t (assoc :dependents depends-on-t))] - (if targets - (if-let [task (get tasks t)] - (recur (str prog "\n" (assemble-task-1 task-map task parallel?)) - targets - (conj done t) - (concat extra-paths (:extra-paths task)) - (merge extra-deps (:extra-deps task)) - (concat requires (:requires task))) - [(binding [*out* *err*] - (println "No such task:" t)) 1]) - (if-let [task (get tasks t)] - (let [prog (str prog "\n" - #_(wait-tasks depends) #_(apply str (map deref-task depends)) - "\n" - (assemble-task-1 task-map task parallel? true)) - extra-paths (concat extra-paths (:extra-paths task)) - extra-deps (merge extra-deps (:extra-deps task)) - requires (concat requires (:requires task))] - [[(format-task init extra-paths extra-deps requires prog)] nil]) - [(binding [*out* *err*] - (println "No such task:" t)) 1])))))) - [[(format-task - init - (:extra-paths task) - (:extra-deps task) - (concat requires (:requires task)) - (assemble-task-1 (cond-> {:name task-name} - enter (assoc :enter enter) - leave (assoc :leave leave) - parallel? (assoc :parallel parallel?)) - task parallel? true))] nil])] - (when @debug - (binding [*out* *err*] - (println (ffirst prog)))) - prog) - [(binding [*out* *err*] - (println "No such task:" task-name)) 1]))) + (binding [*print-meta* true] + (if task + (let [m? (map? task) + requires (get tasks :requires) + init (get tasks :init) + prog (if (when m? (:depends task)) + (let [[targets error] + (try [(target-order tasks task-name)] + (catch clojure.lang.ExceptionInfo e + [nil (ex-message e)])) + task-map (cond-> {} + enter (assoc :enter enter) + leave (assoc :leave leave) + parallel? (assoc :parallel parallel?))] + (if error + [(binding [*out* *err*] + (println error)) 1] + (loop [prog "" + targets (seq targets) + done [] + extra-paths [] + extra-deps nil + requires requires] + (let [t (first targets) + targets (next targets) + task-map (assoc task-map + :name t)] + (if targets + (if-let [task (get tasks t)] + (recur (str prog "\n" (assemble-task-1 task-map task parallel?)) + targets + (conj done t) + (concat extra-paths (:extra-paths task)) + (merge extra-deps (:extra-deps task)) + (concat requires (:requires task))) + [(binding [*out* *err*] + (println "No such task:" t)) 1]) + (if-let [task (get tasks t)] + (let [prog (str prog "\n" + #_(wait-tasks depends) #_(apply str (map deref-task depends)) + "\n" + (assemble-task-1 task-map task parallel? true)) + extra-paths (concat extra-paths (:extra-paths task)) + extra-deps (merge extra-deps (:extra-deps task)) + requires (concat requires (:requires task))] + [[(format-task init extra-paths extra-deps requires prog)] nil]) + [(binding [*out* *err*] + (println "No such task:" t)) 1])))))) + [[(format-task + init + (:extra-paths task) + (:extra-deps task) + (concat requires (:requires task)) + (assemble-task-1 (cond-> {:name task-name} + enter (assoc :enter enter) + leave (assoc :leave leave) + parallel? (assoc :parallel parallel?)) + task parallel? true))] nil])] + (when @debug + (binding [*out* *err*] + (println (ffirst prog)))) + prog) + [(binding [*out* *err*] + (println "No such task:" task-name)) 1])))) (defn doc-from-task [sci-ctx tasks task] (or (:doc task) diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index ae73f7fa..cf46d948 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -236,7 +236,16 @@ :task (do (Thread/sleep 10) (+ 1 2 3))} c (do (Thread/sleep 10) :c)}} - (is (= [6 6 :c] (bb "run" "--prn" "a"))))))) + (is (= [6 6 :c] (bb "run" "--prn" "a")))))) + (testing "dynamic vars" + (test-utils/with-config '{:tasks + {:init (def ^:dynamic *foo* true) + a (do + (def ^:dynamic *bar* false) + (binding [*foo* false + *bar* true] + [*foo* *bar*]))}} + (is (= [false true] (bb "run" "--prn" "a")))))) (deftest list-tasks-test (test-utils/with-config {} From ac576bd6e74089e613951163d54524f4213f5566 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 11:36:30 +0200 Subject: [PATCH 23/83] [#865] Stable namespace --- src/babashka/impl/tasks.clj | 4 +++- test/babashka/bb_edn_test.clj | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/babashka/impl/tasks.clj b/src/babashka/impl/tasks.clj index ab6c24b1..9b870449 100644 --- a/src/babashka/impl/tasks.clj +++ b/src/babashka/impl/tasks.clj @@ -225,6 +225,8 @@ prog (wrap-def task-map prog parallel? last?)] prog))))) +(def rand-ns (delay (symbol (str "user-" (java.util.UUID/randomUUID))))) + (defn format-task [init extra-paths extra-deps requires prog] (format " %s ;; extra-paths @@ -255,7 +257,7 @@ (if (seq extra-deps) (format "(babashka.deps/add-deps '%s)" (pr-str {:deps extra-deps})) "") - (gensym "user") + @rand-ns (if (seq requires) (format "(:require %s)" (str/join " " requires)) "") diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index cf46d948..6c43a6ea 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -245,7 +245,19 @@ (binding [*foo* false *bar* true] [*foo* *bar*]))}} - (is (= [false true] (bb "run" "--prn" "a")))))) + (is (= [false true] (bb "run" "--prn" "a"))))) + (testing "stable namespace name" + (test-utils/with-config '{:tasks + {:init (do (def ^:dynamic *jdk*) + (def ^:dynamic *server*)) + server [*jdk* *server*] + run-all (for [jdk [8 11 15] + server [:foo :bar]] + (binding [*jdk* jdk + *server* server] + (babashka.tasks/run 'server)))}} + (is (= '([8 :foo] [8 :bar] [11 :foo] [11 :bar] [15 :foo] [15 :bar]) + (bb "run" "--prn" "run-all")))))) (deftest list-tasks-test (test-utils/with-config {} From 35874fa5ce0998af0385a1235c3c3eec3f595d81 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 12:23:41 +0200 Subject: [PATCH 24/83] babashka.nrepl#40 --- babashka.nrepl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babashka.nrepl b/babashka.nrepl index d9b63bba..3c96750b 160000 --- a/babashka.nrepl +++ b/babashka.nrepl @@ -1 +1 @@ -Subproject commit d9b63bbadce04799ef791c02a7066dd3197aa1b9 +Subproject commit 3c96750be104fa2d227a257b8c69b0b8b9e8a8ef From 82625b57dd2b59abff7f2522b6d4f3adfa3ff18b Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 12:30:06 +0200 Subject: [PATCH 25/83] Tasks: fix edge case --- src/babashka/impl/tasks.clj | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/babashka/impl/tasks.clj b/src/babashka/impl/tasks.clj index 9b870449..2ffbf5cc 100644 --- a/src/babashka/impl/tasks.clj +++ b/src/babashka/impl/tasks.clj @@ -158,17 +158,17 @@ (format " (let [chans (filter babashka.tasks/-chan? %s)] (loop [cs chans] - (let [[v p] (clojure.core.async/alts!! cs) - [task-name v] v - cs (filterv #(not= p %%) cs) - ;; _ (.println System/err (str \"n: \" task-name \" v: \" v)) - ;; check for existence of v, as the channel may already have been consumed once - _ (when v (intern *ns* (symbol task-name) v))] - (when (instance? Throwable v) - (throw (ex-info (ex-message v) - {:babashka/exit 1 - :data (ex-data v)}))) - (when (seq cs) + (when (seq cs) + (let [[v p] (clojure.core.async/alts!! cs) + [task-name v] v + cs (filterv #(not= p %%) cs) + ;; _ (.println System/err (str \"n: \" task-name \" v: \" v)) + ;; check for existence of v, as the channel may already have been consumed once + _ (when v (intern *ns* (symbol task-name) v))] + (when (instance? Throwable v) + (throw (ex-info (ex-message v) + {:babashka/exit 1 + :data (ex-data v)}))) (recur cs)))))" deps) "") #_(format "(def %s (babashka.tasks/-wait %s))" dep dep)) From d1cee42c9d518afd2052c46c6105c5036081cac0 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 13:18:19 +0200 Subject: [PATCH 26/83] CHANGELOG [skip ci] --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37945b19..a97755fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ For a list of breaking changes, check [here](#breaking-changes). +## Unreleased + +Babashka proper: + +- Print ex-data in error report [#730](https://github.com/babashka/babashka/issues/730) ([@GreshamDanielStephens](https://github.com/GreshamDanielStephens), [@rng-dynamics](https://github.com/rng-dynamics)) +- Support dynamic vars in tasks [#865](https://github.com/babashka/babashka/issues/865) +- Use stable namespace when using `run` in tasks [#865](https://github.com/babashka/babashka/issues/865) + +Babashka.nrepl: + +- Error reporting improvement [#40](https://github.com/babashka/babashka.nrepl/issues/865) + ## 0.4.3 - Add `cognitect.transit/tagged-value`, needed for sql pods From dceb3d7f104968a3e8452eedd31b5c9f3af5bf4a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 21:35:52 +0200 Subject: [PATCH 27/83] sci: interop refactor --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index a8505dd4..3578ffe7 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit a8505dd4ee0b5cc7e6f6215f1bbc136c6d4ae7ee +Subproject commit 3578ffe7a2455f3659c401018dd99207311b663c From 8efc710fb3cd3d07a10a3af4564600cbfd95c4ac Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 21:37:03 +0200 Subject: [PATCH 28/83] sci: interop refactor --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 3578ffe7..46d89488 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 3578ffe7a2455f3659c401018dd99207311b663c +Subproject commit 46d8948863f3d33f98910a79f8cf9c3f566a776e From 4bb2ba8b2c053b770d9cc5b92eb3ea188c809440 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 22:11:30 +0200 Subject: [PATCH 29/83] sci: in-ns minor --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 46d89488..94f88ef0 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 46d8948863f3d33f98910a79f8cf9c3f566a776e +Subproject commit 94f88ef07bb473540380c27179f5cc4b24b7601f From 524a260c26c5ea6253f1125ad52e82a469535932 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 30 May 2021 23:24:31 +0200 Subject: [PATCH 30/83] sci: minor cleanup --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 94f88ef0..3f352d0d 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 94f88ef07bb473540380c27179f5cc4b24b7601f +Subproject commit 3f352d0dfb97e1ee711f0cc8fffe97304313d13d From 42bf790068ec2d12e4340665eba889cf940dd626 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 31 May 2021 00:06:21 +0200 Subject: [PATCH 31/83] [#872] Add java.lang.ProcessHandle$Info (#873) And java.util.Optional --- src/babashka/impl/classes.clj | 4 ++++ test/babashka/main_test.clj | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index a148b8f9..d45fe36f 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -132,6 +132,7 @@ java.lang.Object java.lang.Process java.lang.ProcessHandle + java.lang.ProcessHandle$Info java.lang.ProcessBuilder java.lang.ProcessBuilder$Redirect java.lang.Runtime @@ -247,6 +248,7 @@ java.util.Locale java.util.Map java.util.MissingResourceException + java.util.Optional java.util.Properties java.util.Set java.util.UUID @@ -344,6 +346,8 @@ java.lang.Process (instance? java.lang.ProcessHandle v) java.lang.ProcessHandle + (instance? java.lang.ProcessHandle$Info v) + java.lang.ProcessHandle$Info ;; added for calling .put on .environment from ProcessBuilder (instance? java.util.Map v) java.util.Map diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 4fb329b3..7c38d419 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -468,8 +468,8 @@ ;; 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")))))) + (catch Exception e + (is (str/includes? (str e) "timed out")))))) (deftest get-message-on-exception-info-test (is "foo" (bb nil "(try (throw (ex-info \"foo\" {})) (catch Exception e (.getMessage e)))"))) @@ -639,6 +639,14 @@ true"))) (is (str/blank? (with-out-str (main/main "doc" "non-existing")))) (is (= 1 (main/main "doc" "non-existing"))))) +(deftest process-handler-info-test + (when test-utils/native? + (is (= ["-e" "(vec (.get (.arguments (.info (java.lang.ProcessHandle/current)))))"] + (bb nil "-e" "(vec (.get (.arguments (.info (java.lang.ProcessHandle/current)))))"))) + (is (str/ends-with? + (bb nil "-e" "(.get (.command (.info (java.lang.ProcessHandle/current))))") + "bb")))) + ;;;; Scratch (comment From a8f5ef728744b48ea5c4b8b34554beab6d6bef03 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 31 May 2021 00:08:06 +0200 Subject: [PATCH 32/83] CHANGELOG [skip ci] --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a97755fb..15f7e98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Babashka proper: - Print ex-data in error report [#730](https://github.com/babashka/babashka/issues/730) ([@GreshamDanielStephens](https://github.com/GreshamDanielStephens), [@rng-dynamics](https://github.com/rng-dynamics)) - Support dynamic vars in tasks [#865](https://github.com/babashka/babashka/issues/865) - Use stable namespace when using `run` in tasks [#865](https://github.com/babashka/babashka/issues/865) +- Add `java.lang.ProcessHandle$Info` [#872](https://github.com/babashka/babashka/issues/872) +- Add `java.util.Optional` [#872](https://github.com/babashka/babashka/issues/872) Babashka.nrepl: From b0490a01610b6fa943caeb1d27fecf43ac40cc8c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 31 May 2021 10:34:02 +0200 Subject: [PATCH 33/83] CHANGELOG [skip ci] --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15f7e98a..1d5aa593 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ For a list of breaking changes, check [here](#breaking-changes). Babashka proper: - Print ex-data in error report [#730](https://github.com/babashka/babashka/issues/730) ([@GreshamDanielStephens](https://github.com/GreshamDanielStephens), [@rng-dynamics](https://github.com/rng-dynamics)) -- Support dynamic vars in tasks [#865](https://github.com/babashka/babashka/issues/865) -- Use stable namespace when using `run` in tasks [#865](https://github.com/babashka/babashka/issues/865) +- Tasks: support dynamic vars [#865](https://github.com/babashka/babashka/issues/865) +- Tasks: use stable namespace when using `run` [#865](https://github.com/babashka/babashka/issues/865) - Add `java.lang.ProcessHandle$Info` [#872](https://github.com/babashka/babashka/issues/872) - Add `java.util.Optional` [#872](https://github.com/babashka/babashka/issues/872) From cc26984ab7c85e2200bf2bf98761c264706aa261 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 31 May 2021 14:28:45 +0200 Subject: [PATCH 34/83] Update babashka.nrepl --- babashka.nrepl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babashka.nrepl b/babashka.nrepl index 3c96750b..bd1ce0cb 160000 --- a/babashka.nrepl +++ b/babashka.nrepl @@ -1 +1 @@ -Subproject commit 3c96750be104fa2d227a257b8c69b0b8b9e8a8ef +Subproject commit bd1ce0cbc0861350a4a36e9c31ef79fa0c7cff84 From fa82ec5087c38062b75d1c32f1f80a190d0eff0a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:12:41 +0200 Subject: [PATCH 35/83] sci: support trailing metadata in defn --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 3f352d0d..ad1c932f 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 3f352d0dfb97e1ee711f0cc8fffe97304313d13d +Subproject commit ad1c932f19914d1453f8e070b2f7fc2739ddd7fc From 97298ab0f100962ce8dd3bf19957219545671bd7 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:13:30 +0200 Subject: [PATCH 36/83] CHANGELOG [skip ci] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d5aa593..98f92caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ Babashka.nrepl: - Error reporting improvement [#40](https://github.com/babashka/babashka.nrepl/issues/865) +Sci: + +- Support trailing metadata in `defn` + ## 0.4.3 - Add `cognitect.transit/tagged-value`, needed for sql pods From e7bcb2170ac226144a1263d9becb9eeeeaedae39 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:29:17 +0200 Subject: [PATCH 37/83] Additional fix for borkdude/sci#567 --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index ad1c932f..725bb4b0 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit ad1c932f19914d1453f8e070b2f7fc2739ddd7fc +Subproject commit 725bb4b04c7f5ffe94a97c104b37abb17c7bbb68 From beb7d8a9a80a31941eddc3e16235c37784134211 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:45:12 +0200 Subject: [PATCH 38/83] Add java.lang.StackTraceElement --- src/babashka/impl/classes.clj | 1 + src/babashka/main.clj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index d45fe36f..4a82fba4 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -138,6 +138,7 @@ java.lang.Runtime java.lang.RuntimeException java.lang.Short + java.lang.StackTraceElement java.lang.String java.lang.StringBuilder java.lang.System diff --git a/src/babashka/main.clj b/src/babashka/main.clj index b0328a8a..1eabc8f6 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -426,6 +426,7 @@ Use bb run --help to show this help output. Process java.lang.Process ProcessBuilder java.lang.ProcessBuilder Short java.lang.Short + StackTraceElement java.lang.StackTraceElement String java.lang.String StringBuilder java.lang.StringBuilder System java.lang.System From e833fb270347ca776414aae1dfae306d85cf3a2c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:46:53 +0200 Subject: [PATCH 39/83] CHANGELOG [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98f92caa..1f651c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Babashka proper: - Tasks: use stable namespace when using `run` [#865](https://github.com/babashka/babashka/issues/865) - Add `java.lang.ProcessHandle$Info` [#872](https://github.com/babashka/babashka/issues/872) - Add `java.util.Optional` [#872](https://github.com/babashka/babashka/issues/872) +- Add `java.lang.StackTraceElement` (to gain compatibility with libraries such as [omniconf](https://github.com/grammarly/omniconf)) Babashka.nrepl: From 3a9022be04d97b2f9fbda72ad2259cb8e017726c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:47:04 +0200 Subject: [PATCH 40/83] v0.4.4 --- resources/BABASHKA_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/BABASHKA_VERSION b/resources/BABASHKA_VERSION index 86e5b12e..b300caa3 100644 --- a/resources/BABASHKA_VERSION +++ b/resources/BABASHKA_VERSION @@ -1 +1 @@ -0.4.4-SNAPSHOT \ No newline at end of file +0.4.4 \ No newline at end of file From 6bd17bad98242039bf2525fc8c5f6b3dcd0d29e2 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:50:36 +0200 Subject: [PATCH 41/83] CHANGELOG [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f651c93..98039cf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ For a list of breaking changes, check [here](#breaking-changes). -## Unreleased +## 0.4.4 Babashka proper: From 952af312961d120d9d54e5cce78835f452986fca Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 11:58:53 +0200 Subject: [PATCH 42/83] doc [skip ci] --- doc/projects.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/projects.md b/doc/projects.md index fd535537..7e2bf28a 100644 --- a/doc/projects.md +++ b/doc/projects.md @@ -39,6 +39,7 @@ The following libraries and projects are known to work with babashka. - [binf](#binf) - [rewrite-edn](#rewrite-edn) - [expound](#expound) + - [omniconf](#omniconf) - [Pods](#pods) - [Projects](#projects-1) - [babashka-test-action](#babashka-test-action) @@ -545,6 +546,30 @@ Example: (expound/expound ::a [1 2]) ``` +### [omniconf](https://github.com/grammarly/omniconf) + +script.clj: +``` clojure +#!/usr/bin/env bb + +(ns script + (:require [babashka.deps :as deps])) + +(deps/add-deps + '{:deps {com.grammarly/omniconf {:mvn/version "0.4.3"}}}) + +(require '[omniconf.core :as cfg]) +(cfg/define {:foo {}}) +(cfg/populate-from-env) +(cfg/get :foo) +``` + +``` text +FOO=1 script.clj +Populating Omniconf from env: 1 value(s) +"1" +``` + ## Pods [Babashka pods](https://github.com/babashka/babashka.pods) are programs that can From dddc32adfd8d0fb7116e127ab76e4c8c67b57dce Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 1 Jun 2021 12:08:31 +0200 Subject: [PATCH 43/83] Version bump --- resources/BABASHKA_RELEASED_VERSION | 2 +- resources/BABASHKA_VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/BABASHKA_RELEASED_VERSION b/resources/BABASHKA_RELEASED_VERSION index 70d5b25f..b300caa3 100644 --- a/resources/BABASHKA_RELEASED_VERSION +++ b/resources/BABASHKA_RELEASED_VERSION @@ -1 +1 @@ -0.4.3 \ No newline at end of file +0.4.4 \ No newline at end of file diff --git a/resources/BABASHKA_VERSION b/resources/BABASHKA_VERSION index b300caa3..416fd598 100644 --- a/resources/BABASHKA_VERSION +++ b/resources/BABASHKA_VERSION @@ -1 +1 @@ -0.4.4 \ No newline at end of file +0.4.5-SNAPSHOT \ No newline at end of file From d4bf1d1a1de56a8b5abaf4689d7f1bbacb685bf2 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 12:02:31 +0200 Subject: [PATCH 44/83] sci: clean up symbol resolution --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 725bb4b0..87cf475a 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 725bb4b04c7f5ffe94a97c104b37abb17c7bbb68 +Subproject commit 87cf475abff2b2004eeb279faac32f3affc660d0 From c71beafcd36c7fdde2b1db3e38103fdd8fe8adea Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 16:18:00 +0200 Subject: [PATCH 45/83] sci: minor fn enhance --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 87cf475a..226677ce 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 87cf475abff2b2004eeb279faac32f3affc660d0 +Subproject commit 226677ce6bffccf0c68f75115cb374ec192d72be From d8ea84405897611e33337c81844cef044b6d9d0e Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 18:01:22 +0200 Subject: [PATCH 46/83] sci: minor fn optimization --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 226677ce..30b64bf8 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 226677ce6bffccf0c68f75115cb374ec192d72be +Subproject commit 30b64bf8ecdc1a744756d9b00ae63a249bffe6c5 From 99475511e061c19c556d919bbde1103ca732f9d6 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 20:13:00 +0200 Subject: [PATCH 47/83] sci: fn destructure at analysis --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 30b64bf8..e3d2d9d3 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 30b64bf8ecdc1a744756d9b00ae63a249bffe6c5 +Subproject commit e3d2d9d3e7fbc8c7328acb92e158c1d56a2a6731 From ef4bd8e5f6e0a945c913cb502fc8934ee73022d9 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 20:48:47 +0200 Subject: [PATCH 48/83] sci: count at analysis time --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index e3d2d9d3..a05bb53b 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit e3d2d9d3e7fbc8c7328acb92e158c1d56a2a6731 +Subproject commit a05bb53b65012dcff6cd1ee7ca03451c3f7311e0 From 5d89c623c33c991a13d19040c43006fde8f462e9 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 21:18:01 +0200 Subject: [PATCH 49/83] sci: minor --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index a05bb53b..650127f7 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit a05bb53b65012dcff6cd1ee7ca03451c3f7311e0 +Subproject commit 650127f705462b2fa4399a7f098e9b8c44b009e4 From 957f97fd15d60d724689e708e59b0d9d12e6c59a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 21:39:44 +0200 Subject: [PATCH 50/83] sci: revert optimizations --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 650127f7..811803df 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 650127f705462b2fa4399a7f098e9b8c44b009e4 +Subproject commit 811803df584d09047a1c77461557689398d7e47c From 225c04d784718e4d2d776417622aa735f433c37a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 2 Jun 2021 23:34:59 +0200 Subject: [PATCH 51/83] sci: minor --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 811803df..8c8bc854 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 811803df584d09047a1c77461557689398d7e47c +Subproject commit 8c8bc8548a608dd0387ef9a9c85352816e3600b8 From 3764b52f3a00b23d23519d436c1a5de644de5945 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 3 Jun 2021 00:25:57 +0200 Subject: [PATCH 52/83] Implement custom deref outside of sci --- sci | 2 +- src/babashka/main.clj | 15 +++++++++------ test/babashka/main_test.clj | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/sci b/sci index 8c8bc854..d44c5b79 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 8c8bc8548a608dd0387ef9a9c85352816e3600b8 +Subproject commit d44c5b792e572ad4f13afeb3abc957272a455fa9 diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 1eabc8f6..1c25c94f 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -44,6 +44,7 @@ [sci.core :as sci] [sci.impl.namespaces :as sci-namespaces] [sci.impl.unrestrict :refer [*unrestricted*]] + [sci.impl.utils :refer [ctx-fn]] [sci.impl.vars :as vars]) (:gen-class)) @@ -308,9 +309,15 @@ Use bb run --help to show this help output. 'start-server (fn [& args] (apply server/start-server @common/ctx args))}) +(def input-var (sci/new-dynamic-var '*input*)) + (def namespaces (cond-> - {'clojure.tools.cli tools-cli-namespace + {'user {'*input* (ctx-fn + (fn [_ctx] + (force @input-var)) + nil)} + 'clojure.tools.cli tools-cli-namespace 'clojure.java.shell shell-namespace 'babashka.wait {'wait-for-port wait/wait-for-port 'wait-for-path wait/wait-for-path} @@ -433,7 +440,6 @@ Use bb run --help to show this help output. Thread java.lang.Thread Throwable java.lang.Throwable}) -(def input-var (sci/new-dynamic-var '*input* nil)) (def edn-readers (cond-> {} features/yaml? (assoc 'ordered/map @(resolve 'flatland.ordered.map/ordered-map)))) @@ -716,10 +722,7 @@ Use bb run --help to show this help output. :namespaces (-> namespaces (assoc 'clojure.core (assoc core-extras - 'load-file load-file*)) - (assoc-in ['user (with-meta '*input* - (when-not stream? - {:sci.impl/deref! true}))] input-var)) + 'load-file load-file*))) :env env :features #{:bb :clj} :classes classes/class-map diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 7c38d419..2103a9e9 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -388,8 +388,7 @@ (is (= "hello" (bb nil "(doto (java.lang.Thread. (fn [] (prn \"hello\"))) (.start) (.join)) nil")))) (deftest dynvar-test - (is (= 1 (bb nil "(binding [*command-line-args* 1] *command-line-args*)"))) - (is (= 1 (bb nil "(binding [*input* 1] *input*)")))) + (is (= 1 (bb nil "(binding [*command-line-args* 1] *command-line-args*)")))) (deftest file-in-error-msg-test (is (thrown-with-msg? Exception #"error.bb" From e5a6c5b7a5fc18011abbf5218b57af08e89521a3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 3 Jun 2021 11:33:40 +0200 Subject: [PATCH 53/83] sci: clean --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index d44c5b79..cca5fd12 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit d44c5b792e572ad4f13afeb3abc957272a455fa9 +Subproject commit cca5fd12912c68f95483eba717b1426d941ca1af From f6e52b37d52ae39dd864e68ba18581c47284e62d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 6 Jun 2021 12:59:52 +0200 Subject: [PATCH 54/83] sci: emit error at analysis time for invalid keyword call --- process | 2 +- sci | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/process b/process index 3559a706..4c6699d0 160000 --- a/process +++ b/process @@ -1 +1 @@ -Subproject commit 3559a70686e435504b1bed320d2e513c5bf2bb15 +Subproject commit 4c6699d06b49773d3e5c5b4c11d3334fb78cc996 diff --git a/sci b/sci index cca5fd12..bfba6fde 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit cca5fd12912c68f95483eba717b1426d941ca1af +Subproject commit bfba6fdef90b7cc2a171057f22e7aee17a345718 From fcc57e08bc0db45f64ec09f4f3959cb0ebb27efa Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 6 Jun 2021 13:56:21 +0200 Subject: [PATCH 55/83] sci: return direct fn call --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index bfba6fde..91fe655b 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit bfba6fdef90b7cc2a171057f22e7aee17a345718 +Subproject commit 91fe655bd79c4ca0dc3b7e5a69896ec68df4a45a From cc21fcc9ef7f71ccde836e055c9d04f4a9dc798b Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 6 Jun 2021 20:59:36 +0200 Subject: [PATCH 56/83] sci: more ctx-fn --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 91fe655b..dda1a566 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 91fe655bd79c4ca0dc3b7e5a69896ec68df4a45a +Subproject commit dda1a56635a3080cef50e7b657bbf1ee8b1d51a0 From 9af436a0d467e6d26e3bfd01ac3882d73e5a425f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 7 Jun 2021 20:20:28 +0200 Subject: [PATCH 57/83] Add java.net.InetSocketAddress (#878) --- src/babashka/impl/classes.clj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index 4a82fba4..fb2a7a25 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -152,6 +152,7 @@ java.net.DatagramPacket java.net.HttpURLConnection java.net.InetAddress + java.net.InetSocketAddress java.net.ServerSocket java.net.Socket java.net.SocketException From ac8f9b4f8f3fbe98516e75b377d169999b9d45e4 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 8 Jun 2021 11:36:31 +0200 Subject: [PATCH 58/83] Sci: get rid of call via meta op --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index dda1a566..0b119646 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit dda1a56635a3080cef50e7b657bbf1ee8b1d51a0 +Subproject commit 0b119646375084c2b447c3ce54e8775a194233a4 From c1f621930d9da8464b6ffd6f00eb89724e162802 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 8 Jun 2021 15:20:54 +0200 Subject: [PATCH 59/83] sci: Get rid of static via meta call --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 0b119646..3f60aa5b 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 0b119646375084c2b447c3ce54e8775a194233a4 +Subproject commit 3f60aa5b9996d68b0e4248318ed91bc27f8dea86 From d6ac0687d9b86dda34612c57aa53990ae937d21f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 8 Jun 2021 15:31:23 +0200 Subject: [PATCH 60/83] sci: Get rid of static via meta call --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 3f60aa5b..2bcc011f 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 3f60aa5b9996d68b0e4248318ed91bc27f8dea86 +Subproject commit 2bcc011fc56073819105230e314807051ec2b90e From 267c478e588e74107abfd368ad68f51e993282af Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 8 Jun 2021 15:40:23 +0200 Subject: [PATCH 61/83] sci: only case for CLJS --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index 2bcc011f..b6d769ed 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 2bcc011fc56073819105230e314807051ec2b90e +Subproject commit b6d769ed45aa17614915e986bd8ab1c8828f908e From 426e97d1dfa868593c67eba907630764740d958e Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 8 Jun 2021 17:40:58 +0200 Subject: [PATCH 62/83] sci: get rid of eval-call --- sci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci b/sci index b6d769ed..79376504 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit b6d769ed45aa17614915e986bd8ab1c8828f908e +Subproject commit 7937650453b7ba9eb9ee43ea30b333b5950dc21e From 15e54ef0a1458b3447edceb39f5dcd9757701d94 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 10:39:43 +0200 Subject: [PATCH 63/83] Add support for slingshot #675 (#881) * Add java.util.Arrays/copyOfRange for slingshot * add exception for tests * Add slingshot tests --- deps.edn | 3 +- src/babashka/impl/classes.clj | 4 +- .../lib_tests/babashka/run_all_libtests.clj | 6 + .../lib_tests/slingshot/slingshot_test.clj | 516 ++++++++++++++++++ .../lib_tests/slingshot/support_test.clj | 111 ++++ .../lib_tests/slingshot/test_test.clj | 8 + 6 files changed, 646 insertions(+), 2 deletions(-) create mode 100644 test-resources/lib_tests/slingshot/slingshot_test.clj create mode 100644 test-resources/lib_tests/slingshot/support_test.clj create mode 100644 test-resources/lib_tests/slingshot/test_test.clj diff --git a/deps.edn b/deps.edn index 6d3bca04..ec064874 100644 --- a/deps.edn +++ b/deps.edn @@ -78,7 +78,8 @@ gaka/gaka {:mvn/version "0.3.0"} failjure/failjure {:mvn/version "2.1.1"} io.helins/binf {:mvn/version "1.1.0-beta0"} - rm-hull/jasentaa {:mvn/version "0.2.5"}} + rm-hull/jasentaa {:mvn/version "0.2.5"} + slingshot/slingshot {:mvn/version "0.12.2"}} :classpath-overrides {org.clojure/clojure nil org.clojure/spec.alpha nil org.clojure/core.specs.alpha nil}} diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index fb2a7a25..81522456 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -71,7 +71,8 @@ {:name "toString"} {:name "toURI"}]} java.util.Arrays - {:methods [{:name "copyOf"}]} + {:methods [{:name "copyOf"} + {:name "copyOfRange"}]} ;; this fixes clojure.lang.Reflector for Java 11 java.lang.reflect.AccessibleObject {:methods [{:name "canAccess"}]}} @@ -235,6 +236,7 @@ java.time.temporal.Temporal java.time.temporal.TemporalAccessor java.time.temporal.TemporalAdjuster]) + java.util.concurrent.ExecutionException java.util.concurrent.LinkedBlockingQueue java.util.jar.JarFile java.util.jar.JarEntry diff --git a/test-resources/lib_tests/babashka/run_all_libtests.clj b/test-resources/lib_tests/babashka/run_all_libtests.clj index cc4e3c70..e7dd18d3 100644 --- a/test-resources/lib_tests/babashka/run_all_libtests.clj +++ b/test-resources/lib_tests/babashka/run_all_libtests.clj @@ -212,6 +212,12 @@ 'honey.sql.helpers-test 'honey.sql.postgres-test) +(test-namespaces 'slingshot.slingshot-test + 'slingshot.support-test + ;; TODO: + ;; 'slingshot.test-test + ) + ;;;; final exit code (let [{:keys [:test :fail :error] :as m} @status] diff --git a/test-resources/lib_tests/slingshot/slingshot_test.clj b/test-resources/lib_tests/slingshot/slingshot_test.clj new file mode 100644 index 00000000..09938332 --- /dev/null +++ b/test-resources/lib_tests/slingshot/slingshot_test.clj @@ -0,0 +1,516 @@ +(ns slingshot.slingshot-test + (:require [clojure.test :refer :all] + [slingshot.slingshot :refer :all] + [clojure.string :as str]) + (:import java.util.concurrent.ExecutionException)) + +(defrecord exception-record [error-code duration-ms message]) +(defrecord x-failure [message]) + +(def a-sphere ^{:type ::sphere} {:radius 3}) + +(def h1 (derive (make-hierarchy) ::square ::shape)) +(def a-square ^{:type ::square} {:size 4}) + +(def exception-1 (Exception. "exceptional")) +(def exception-record-1 (exception-record. 6 1000 "pdf failure")) + +(defn mult-func [x y] + (let [a 7 b 11] + (if (= x 3) + (* a b x y) + (throw+ (x-failure. "x isn't 3... really??"))))) + +(defmacro mega-try [body] + `(try+ + ~body + + ;; by class derived from Throwable + (catch IllegalArgumentException e# + [:class-iae e#]) + (catch Exception e# + [:class-exception e#]) + + ;; by java class generically + (catch String e# + [:class-string e#]) + + ;; by clojure record type + (catch exception-record e# + [:class-exception-record e#]) + + ;; by key-value + (catch [:a-key 4] e# + [:key-yields-value e#]) + + ;; by multiple-key-value + (catch [:key1 4 :key2 5] e# + [:keys-yield-values e#]) + + ;; by key present + (catch (and (set? ~'%) (contains? ~'% :a-key)) e# + [:key-is-present e#]) + + ;; by clojure type, with optional hierarchy + (catch (isa? (type ~'%) ::sphere) e# + [:type-sphere (type e#) e#]) + (catch (isa? h1 (type ~'%) ::shape) e# + [:type-shape-in-h1 (type e#) e#]) + + ;; by predicate + (catch nil? e# + [:pred-nil e#]) + (catch keyword? e# + [:pred-keyword e#]) + (catch symbol? e# + [:pred-symbol e#]) + (catch map? e# + [:pred-map e# (meta e#)]))) + +(deftest test-try+ + (testing "catch by class derived from Throwable" + (testing "treat throwables exactly as throw does, interop with try/throw" + (is (= [:class-exception exception-1] + (mega-try (throw+ exception-1)) + (mega-try (throw exception-1)) + (try (throw+ exception-1) + (catch Exception e [:class-exception e])) + (try (throw exception-1) + (catch Exception e [:class-exception e]))))) + (testing "IllegalArgumentException thrown by clojure/core" + (is (= :class-iae (first (mega-try (str/replace "foo" 1 1))))))) + + (testing "catch by java class generically" + (is (= [:class-string "fail"] (mega-try (throw+ "fail"))))) + + #_(testing "catch by clojure record type" + (is (= [:class-exception-record exception-record-1] + (mega-try (throw+ exception-record-1))))) + + (testing "catch by key is present" + (is (= [:key-is-present #{:a-key}] (mega-try (throw+ #{:a-key}))))) + + (testing "catch by keys and values" + (is (= [:key-yields-value {:a-key 4}] (mega-try (throw+ {:a-key 4})))) + (is (= [:keys-yield-values {:key1 4 :key2 5}] + (mega-try (throw+ {:key1 4 :key2 5}))))) + + (testing "catch by clojure type with optional hierarchy" + (is (= [:type-sphere ::sphere a-sphere] (mega-try (throw+ a-sphere)))) + (is (= [:type-shape-in-h1 ::square a-square] (mega-try (throw+ a-square))))) + + (testing "catch by predicate" + (is (= [:pred-nil nil] (mega-try (throw+ nil)))) + (is (= [:pred-keyword :awesome] (mega-try (throw+ :awesome)))) + (is (= [:pred-symbol 'yuletide] (mega-try (throw+ 'yuletide)))) + (is (= [:pred-map {:error-code 4} nil] (mega-try (throw+ {:error-code 4})))) + (testing "preservation of metadata" + (is (= [:pred-map {:error-code 4} {:severity 4}] + (mega-try (throw+ ^{:severity 4} {:error-code 4}))))))) + +(deftest test-clauses + (let [bumps (atom 0) + bump (fn [] (swap! bumps inc))] + (is (nil? (try+))) + (is (nil? (try+ (catch integer? i (inc i))))) + (is (nil? (try+ (finally (bump))))) + (is (nil? (try+ (catch integer? i (inc i)) (finally (bump))))) + (is (nil? (try+ (catch integer? i (inc i)) (catch map? m m) + (finally (bump))))) + + (is (= 3 (try+ 3))) + (is (= 3 (try+ 3 (catch integer? i 4)))) + (is (= 3 (try+ 3 (finally (bump))))) + (is (= 3 (try+ 3 (catch integer? i 4) (finally (bump))))) + (is (= 4 (try+ (throw+ 3) (catch integer? i (inc i)) (finally (bump))))) + (is (= 4 (try+ (throw+ 3) (catch integer? i (inc i)) (catch map? m m) + (finally (bump))))) + (is (= 4 (try+ (throw+ {:sel 4}) (catch integer? i (inc i)) + (catch map? m (:sel m)) (finally (bump))))) + + (is (= 4 (try+ 3 4))) + (is (= 4 (try+ 3 4 (catch integer? i 4)))) + (is (= 4 (try+ 3 4 (finally (bump))))) + (is (= 4 (try+ 3 4 (catch integer? i 4) (finally (bump))))) + (is (= 5 (try+ (throw+ 4) 4 (catch integer? i (inc i)) (finally (bump))))) + (is (= 11 @bumps)))) + +(defn ax [] (throw+ 1)) +(defn bx [] (try+ (ax) (catch integer? p (throw+ 2)))) +(defn cx [] (try+ (bx) (catch integer? q (throw+ 3)))) +(defn dx [] (try+ (cx) (catch integer? r (throw+ 4)))) +(defn ex [] (try+ (dx) (catch integer? s (throw+ 5)))) +(defn fx [] (try+ (ex) (catch integer? t (throw+ 6)))) +(defn gx [] (try+ (fx) (catch integer? u (throw+ 7)))) +(defn hx [] (try+ (gx) (catch integer? v (throw+ 8)))) +(defn ix [] (try+ (hx) (catch integer? w &throw-context))) + +(defn next-context [x] + (-> x :cause get-throw-context)) + +(deftest test-throw-context + (let [context (ix) + context1 (next-context context) + context2 (next-context context1)] + + (is (= #{:object :message :cause :stack-trace :wrapper :throwable} + (set (keys context)) + (set (keys context1)) + (set (keys context2)))) + (is (= 8 (-> context :object))) + (is (= 7 (-> context1 :object))) + (is (= 6 (-> context2 :object))))) + +(defn e [] + (try+ + (throw (Exception. "uncaught")) + (catch integer? i i))) + +(defn f [] + (try+ + (throw+ 3.2) + (catch integer? i i))) + + +(defn g [] + (try+ + (throw+ 3.2 "wasn't caught") + (catch integer? i i))) + +(deftest test-uncaught + (is (thrown-with-msg? Exception #"^uncaught$" (e))) + (is (thrown-with-msg? Exception #"^throw\+: .*" (f))) + (is (thrown-with-msg? Exception #"wasn't caught" (g)))) + +(defn h [] + (try+ + (try+ + (throw+ 0) + (catch zero? e + (throw+))) + (catch zero? e + :zero))) + +(deftest test-rethrow + (is (= :zero (h)))) + +(defn i [] + (try + (try+ + (doall (map (fn [x] (throw+ (str x))) [1])) + (catch string? x + x)) + (catch Throwable x))) + +(defn j [] + (try+ + (let [fut (future (throw+ "whoops"))] + @fut) + (catch string? e + e))) + +(deftest test-issue-5 + (is (= "1" (i))) + (is (= "whoops" (j)))) + +(deftest test-unmacroed-pct + (is (= :was-eee (try+ (throw+ "eee") + (catch (= % "eee") _ :was-eee) + (catch string? _ :no!))))) + +(deftest test-x-ray-vision + (let [[val wrapper] (try+ + (try + (try + (try + (throw+ "x-ray!") + (catch Throwable x + (throw (RuntimeException. x)))) + (catch Throwable x + (throw (ExecutionException. x)))) + (catch Throwable x + (throw (RuntimeException. x)))) + (catch string? x + [x (:throwable &throw-context)]))] + (is (= "x-ray!" val)) + (is (= "x-ray!" (get-thrown-object wrapper))))) + +(deftest test-catching-wrapper + (let [e (Exception.)] + (try + (try+ + (throw e) + (catch Exception _ + (throw+ :a "msg: %s" %))) + (is false) + (catch Exception s + (is (= "msg: :a" (.getMessage s))) + (is (= e (.getCause s))))))) + +(deftest test-eval-object-once + (let [bumps (atom 0) + bump (fn [] (swap! bumps inc))] + (try+ + (throw+ (bump) "this is it: %s %s %s" % % %) + (catch Object _)) + (is (= @bumps 1)))) + +(deftest test-get-throw-context + (let [object (Object.) + exception1 (Exception.) + exception2 (Exception. "ex1" exception1) + t1 (try + (throw+ object) + (catch Throwable t t)) + t2 (try + (throw+ exception2) + (catch Throwable t t)) + t3 (try + (throw exception2) + (catch Throwable t t))] + (is (= #{:object :message :cause :stack-trace :wrapper + :throwable} + (-> t1 get-throw-context keys set))) + (is (= #{:object :message :cause :stack-trace :throwable} + (-> t2 get-throw-context keys set))) + (is (= #{:object :message :cause :stack-trace :throwable} + (-> t3 get-throw-context keys set))) + + (is (identical? object (:object (get-throw-context t1)))) + (is (identical? exception2 (:object (get-throw-context t2)))) + (is (identical? exception2 (:object (get-throw-context t3)))) + + (is (identical? exception1 (:cause (get-throw-context t2)))) + (is (identical? exception1 (:cause (get-throw-context t3)))) + (is (= "ex1" (:message (get-throw-context t2)))) + (is (= "ex1" (:message (get-throw-context t3)))))) + +(deftest test-get-thrown-object + (let [object (Object.) + exception (Exception.) + t1 (try + (throw+ object) + (catch Throwable t t)) + t2 (try + (throw+ exception) + (catch Throwable t t)) + t3 (try + (throw exception) + (catch Throwable t t))] + (is (identical? object (get-thrown-object t1))) + (is (identical? exception (get-thrown-object t2))) + (is (identical? exception (get-thrown-object t3))))) + +(deftest test-wrapper-and-throwable + (let [context (try+ + (try + (throw+ :afp "wrapper-0") + (catch Exception e + (throw (RuntimeException. "wrapper-1" e)))) + (catch Object _ + &throw-context))] + (is (= "wrapper-0" (.getMessage ^Throwable (:wrapper context)))) + (is (= "wrapper-1" (.getMessage ^Throwable (:throwable context)))))) + +(deftest test-inline-predicate + (is (= :not-caught (try+ + (throw+ {:foo true}) + (catch #(-> % :foo (= false)) data + :caught) + (catch Object _ + :not-caught))))) + +(defn gen-body + [rec-sym throw?] + (let [body `(swap! ~rec-sym #(conj % :body))] + (if throw? + (list 'do body `(throw+ (Exception.))) + body))) + +(defn gen-catch-clause + [rec-sym] + `(catch Exception e# (swap! ~rec-sym #(conj % :catch)))) + +(defn gen-else-clause + [rec-sym broken?] + (let [else-body `(swap! ~rec-sym #(conj % :else))] + (if broken? + (list 'else (list 'do else-body `(throw+ (Exception.)))) + (list 'else else-body)))) + +(defn gen-finally-clause + [rec-sym] + `(finally (swap! ~rec-sym #(conj % :finally)))) + +(defn gen-try-else-form + "Generate variations of (try ... (else ...) ...) forms, which (when eval'd) + will return a vector describing the sequence in which things were evaluated, + e.g. [:body :catch :finally]" + [throw? catch? finally? broken-else?] + (let [rec-sym (gensym "rec") + body (gen-body rec-sym throw?) + catch-clause (if catch? (gen-catch-clause rec-sym)) + else-clause (gen-else-clause rec-sym broken-else?) + finally-clause (if finally? (gen-finally-clause rec-sym))] + `(let [~rec-sym (atom [])] + (try+ + ~(remove nil? `(try+ + ~body + ~catch-clause + ~else-clause + ~finally-clause)) + (catch Object e# + ;; if the inner try+ threw, report it as a :bang! in the return vec + (swap! ~rec-sym #(conj % :bang!)))) + @~rec-sym))) + +(deftest test-else + (doseq [throw? [true false] + catch? [true false] + broken-else? [true false] + finally? [true false]] + (testing (str "test-else: throw? " throw? " catch? " catch? + " broken-else? " broken-else? " finally? " finally?) + (let [try-else-form (gen-try-else-form throw? catch? finally? broken-else?) + actual (eval try-else-form) + expected (vec (remove nil? + [:body + (if (and throw? catch?) :catch) + (if (not throw?) :else) + (if finally? :finally) + ;; expect an escaped exception when either: + ;; a) the else clause runs, and throws + ;; b) the body throws, and is not caught + (if (or (and (not throw?) broken-else?) + (and throw? (not catch?))) :bang!)]))] + (is (= actual expected)))))) + +(deftest test-reflection + (try+ + nil + (catch Exception e + (.getMessage e)))) + +(deftest test-ex-info-compatibility + (let [data {:type :fail :reason :not-found} + message "oops" + wrapper (ex-info message data) + rte1 (RuntimeException. "one" wrapper) + rte2 (RuntimeException. "two" rte1) + direct (try+ + (throw wrapper) + (catch [:type :fail] e + &throw-context) + (catch Object _ + :whoops)) + cause-chain (try+ + (throw rte2) + (catch [:type :fail] e + &throw-context) + (catch Object _ + :whoops))] + (is (= (:object direct) data)) + (is (= (:object cause-chain) data)) + (is (= (:message direct) message)) + (is (= (:message cause-chain) message)) + (is (= (:wrapper direct) wrapper)) + (is (= (:wrapper cause-chain) wrapper)) + (is (= (:throwable direct) wrapper)) + (is (= (:throwable cause-chain) rte2)))) + +;; helpers for test-optional-cause + +(defmacro caught-result [& body] + `(try+ + ~@body + (catch Object ~'o + [(:cause ~'&throw-context) + (:message ~'&throw-context)]))) + +(defmacro caught-result-from-catch [cause & body] + `(caught-result + (try+ + (throw+ ~cause) + (catch Object ~'o + ~@body)))) + +(deftest test-optional-cause + (let [imp (Exception. "I did it implicitly.") + exp (Exception. "I did it explicitly.") + def-msg "throw+: 1" + msg "message two %s" + fmt "aha! %s" + fmt-msg "aha! 1" + fmt2 "%s leading to %s" + fmt2-msg "1 leading to [1 1]" + + ;; throw from outside catch, no implicit cause + + result1 (caught-result (throw+ 1)) + result2 (caught-result (throw+ 1 msg)) + result3 (caught-result (throw+ 1 fmt %)) + result4 (caught-result (throw+ 1 fmt2 % [% %])) + + result5 (caught-result (throw+ 1 nil)) + result6 (caught-result (throw+ 1 nil msg)) + result7 (caught-result (throw+ 1 nil fmt %)) + result8 (caught-result (throw+ 1 nil fmt2 % [% %])) + + result9 (caught-result (throw+ 1 exp)) + result10 (caught-result (throw+ 1 exp msg)) + result11 (caught-result (throw+ 1 exp fmt %)) + result12 (caught-result (throw+ 1 exp fmt2 % [% %])) + + ;; throw from inside catch, implicit cause available + + result13 (caught-result-from-catch imp (throw+)) + + result14 (caught-result-from-catch imp (throw+ 1)) + result15 (caught-result-from-catch imp (throw+ 1 msg)) + result16 (caught-result-from-catch imp (throw+ 1 fmt %)) + result17 (caught-result-from-catch imp (throw+ 1 fmt2 % [% %])) + + result18 (caught-result-from-catch imp (throw+ 1 nil)) + result19 (caught-result-from-catch imp (throw+ 1 nil msg)) + result20 (caught-result-from-catch imp (throw+ 1 nil fmt %)) + result21 (caught-result-from-catch imp (throw+ 1 nil fmt2 % [% %])) + + result22 (caught-result-from-catch imp (throw+ 1 exp)) + result23 (caught-result-from-catch imp (throw+ 1 exp msg)) + result24 (caught-result-from-catch imp (throw+ 1 exp fmt %)) + result25 (caught-result-from-catch imp (throw+ 1 exp fmt2 % [% %]))] + + (testing "outside catch" + (testing "implicit cause" + (is (= result1 [nil def-msg])) + (is (= result2 [nil msg])) + (is (= result3 [nil fmt-msg])) + (is (= result4 [nil fmt2-msg]))) + (testing "erased cause" + (is (= result5 [nil def-msg])) + (is (= result6 [nil msg])) + (is (= result7 [nil fmt-msg])) + (is (= result8 [nil fmt2-msg]))) + (testing "explicit cause" + (is (= result9 [exp def-msg])) + (is (= result10 [exp msg])) + (is (= result11 [exp fmt-msg])) + (is (= result12 [exp fmt2-msg])))) + (testing "inside catch" + (testing "rethrow" + (is (= result13 [nil "I did it implicitly."]))) + (testing "implicit cause" + (is (= result14 [imp def-msg])) + (is (= result15 [imp msg])) + (is (= result16 [imp fmt-msg])) + (is (= result17 [imp fmt2-msg]))) + (testing "erased cause" + (is (= result18 [nil def-msg])) + (is (= result19 [nil msg])) + (is (= result20 [nil fmt-msg])) + (is (= result21 [nil fmt2-msg]))) + (testing "explicit cause" + (is (= result22 [exp def-msg])) + (is (= result23 [exp msg])) + (is (= result24 [exp fmt-msg])) + (is (= result25 [exp fmt2-msg])))))) diff --git a/test-resources/lib_tests/slingshot/support_test.clj b/test-resources/lib_tests/slingshot/support_test.clj new file mode 100644 index 00000000..12d2c142 --- /dev/null +++ b/test-resources/lib_tests/slingshot/support_test.clj @@ -0,0 +1,111 @@ +(ns slingshot.support-test + (:require [clojure.test :refer :all] + [slingshot.slingshot :refer [throw+ try+]] + [slingshot.support :refer :all]) + (:import (java.util.concurrent ExecutionException))) + +(deftest test-parse-try+ + (let [f parse-try+] + (is (= [nil nil nil nil] (f ()))) + + (is (= ['(1) nil nil nil] (f '(1)))) + (is (= [nil '((catch 1)) nil nil] (f '((catch 1))))) + (is (= [nil nil '(else 1) nil] (f '((else 1))))) + (is (= [nil nil nil '(finally 1)] (f '((finally 1))))) + + (is (= ['(1) '((catch 1)) nil nil] (f '(1 (catch 1))))) + (is (= ['(1) nil '(else 1) nil] (f '(1 (else 1))))) + (is (= ['(1) nil nil '(finally 1)] (f '(1 (finally 1))))) + + (is (= ['(1) '((catch 1)) nil '(finally 1)] + (f '(1 (catch 1) (finally 1))))) + (is (= ['(1) '((catch 1) (catch 2)) nil '(finally 1)] + (f '(1 (catch 1) (catch 2) (finally 1))))) + (is (= ['(1) '((catch 1)) '(else 1) nil] + (f '(1 (catch 1) (else 1))))) + (is (= ['(1) '((catch 1) (catch 2)) '(else 1) nil] + (f '(1 (catch 1) (catch 2) (else 1))))) + + (is (= [nil nil '(else 1) '(finally 1)] + (f '((else 1) (finally 1))))) + (is (= ['(1) nil '(else 1) '(finally 1)] + (f '(1 (else 1) (finally 1))))) + (is (= [nil '((catch 1)) '(else 1) nil] + (f '((catch 1) (else 1))))) + (is (= ['(1) '((catch 1)) '(else 1) nil] + (f '(1 (catch 1) (else 1))))) + + (is (thrown? IllegalArgumentException (f '((catch 1) (1))))) + (is (thrown? IllegalArgumentException (f '((finally 1) (1))))) + (is (thrown? IllegalArgumentException (f '((finally 1) (catch 1))))) + (is (thrown? IllegalArgumentException (f '((finally 1) (finally 2))))) + (is (thrown? IllegalArgumentException (f '((else 1) (1))))) + (is (thrown? IllegalArgumentException (f '((else 1) (catch 1))))) + (is (thrown? IllegalArgumentException (f '((else 1) (else 2))))))) + +(defn stack-trace-fn [] + (stack-trace)) + +#_(deftest test-stack-trace + (let [{:keys [methodName className]} (-> (stack-trace-fn) first bean)] + (is (= methodName "invoke")) + (is (re-find #"stack_trace_fn" className)))) + +(deftest test-resolve-local + (let [a 4] + (is (= 4 (resolve-local a))) + (is (nil? (resolve-local b))))) + +(deftest test-wrap + (let [tmessage "test-wrap-1" + tobject 4 + tcause (Exception.) + tstack-trace (stack-trace) + tdata {:object tobject} + tcontext (assoc tdata + :message tmessage + :cause tcause + :stack-trace tstack-trace) + tthrowable (wrap tcontext) + {:keys [message cause data stackTrace]} (bean tthrowable)] + (is (ex-data tthrowable)) + (is (= [message cause (seq stackTrace) data] + [tmessage tcause (seq tstack-trace) tdata])))) + +(def test-hooked (atom nil)) + +(deftest test-throw-hook + (binding [*throw-hook* #(reset! test-hooked %)] + (throw+ "throw-hook-string") + (is (= (set (keys @test-hooked)) + (set [:object :message :cause :stack-trace]))) + (is (= "throw-hook-string" (:object @test-hooked)))) + (binding [*throw-hook* (fn [x] 42)] + (is (= (throw+ "something") 42)))) + +(def catch-hooked (atom nil)) + +(defn catch-hook-return [object] + (fn [x] (assoc x :catch-hook-return object))) + +(defn catch-hook-throw [object] + (fn [x] (assoc x :catch-hook-throw object))) + +(deftest test-catch-hook + (binding [*catch-hook* #(reset! catch-hooked %)] + (try+ (throw+ "catch-hook-string") (catch string? x x)) + (is (= (set (keys @catch-hooked)) + (set [:object :message :cause :stack-trace :wrapper :throwable]))) + (is (= "catch-hook-string" (:object @catch-hooked)))) + (binding [*catch-hook* (catch-hook-return 42)] + (is (= 42 (try+ (throw+ "boo") (catch string? x x))))) + (binding [*catch-hook* (catch-hook-throw (IllegalArgumentException. "bleh"))] + (is (thrown-with-msg? IllegalArgumentException #"bleh" + (try+ (throw+ "boo") (catch string? x x))))) + (is (= "soup!" + (try+ + (binding [*catch-hook* (catch-hook-throw "soup!")] + (try+ + (throw+ "boo") + (catch string? x x))) + (catch string? x x))))) diff --git a/test-resources/lib_tests/slingshot/test_test.clj b/test-resources/lib_tests/slingshot/test_test.clj new file mode 100644 index 00000000..b156c289 --- /dev/null +++ b/test-resources/lib_tests/slingshot/test_test.clj @@ -0,0 +1,8 @@ +(ns slingshot.test-test + (:require [clojure.test :refer :all] + [slingshot.slingshot :refer [throw+]] + [slingshot.test])) + +(deftest test-slingshot-test-macros + (is (thrown+? string? (throw+ "test"))) + (is (thrown+-with-msg? string? #"th" (throw+ "test" "hi there")))) From ac4867daf71362550bcc26172808ea58ed44186c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 10:40:12 +0200 Subject: [PATCH 64/83] Add doc [skip ci] --- doc/projects.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/projects.md b/doc/projects.md index 7e2bf28a..1f75b649 100644 --- a/doc/projects.md +++ b/doc/projects.md @@ -570,6 +570,19 @@ Populating Omniconf from env: 1 value(s) "1" ``` +### [slingshot](https://github.com/scgilardi/slingshot) + +Enhanced try and throw for Clojure leveraging Clojure's capabilities. + +``` text +$ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {slingshot/slingshot {:mvn/version "0.12.2"}}}') +$ bb -e "(require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) (catch [:type ::foo] [] 1))" +1 +``` + +NOTE: slingshot's tests pass with babashka, except for catching record types, +due to a difference in how records are implemented in babashka. + ## Pods [Babashka pods](https://github.com/babashka/babashka.pods) are programs that can From daa8eb06d7acf1a20dcb667a1ba1c8a3cc28a38c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 10:48:33 +0200 Subject: [PATCH 65/83] Add doc [skip ci] --- doc/projects.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/projects.md b/doc/projects.md index 1f75b649..6a111d98 100644 --- a/doc/projects.md +++ b/doc/projects.md @@ -574,14 +574,15 @@ Populating Omniconf from env: 1 value(s) Enhanced try and throw for Clojure leveraging Clojure's capabilities. -``` text +``` clojure $ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {slingshot/slingshot {:mvn/version "0.12.2"}}}') $ bb -e "(require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) (catch [:type ::foo] [] 1))" 1 ``` -NOTE: slingshot's tests pass with babashka, except for catching record types, -due to a difference in how records are implemented in babashka. +NOTE: slingshot's tests pass with babashka, except for catching record types by +name, due to a difference in how records are implemented in babashka. This may +be fixed later if this turns out to be really useful. ## Pods From 18f5c566cc8fe24c807a75401ebc0879f5e062d2 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 10:49:34 +0200 Subject: [PATCH 66/83] Add doc [skip ci] --- doc/projects.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/projects.md b/doc/projects.md index 6a111d98..41737362 100644 --- a/doc/projects.md +++ b/doc/projects.md @@ -580,9 +580,9 @@ $ bb -e "(require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) 1 ``` -NOTE: slingshot's tests pass with babashka, except for catching record types by -name, due to a difference in how records are implemented in babashka. This may -be fixed later if this turns out to be really useful. +NOTE: slingshot's tests pass with babashka except one: catching a record types +by name. This is due to a difference in how records are implemented in +babashka. This may be fixed later if this turns out to be really useful. ## Pods From 9385805423c6663cabb0f8cec87f5c89a8383032 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 15:47:34 +0200 Subject: [PATCH 67/83] STM (#882) --- src/babashka/impl/clojure/core.clj | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/babashka/impl/clojure/core.clj b/src/babashka/impl/clojure/core.clj index a04cb381..62731797 100644 --- a/src/babashka/impl/clojure/core.clj +++ b/src/babashka/impl/clojure/core.clj @@ -1,7 +1,7 @@ (ns babashka.impl.clojure.core {:no-doc true} (:refer-clojure :exclude [future read+string clojure-version with-precision - send-via send send-off]) + send-via send send-off sync]) (:require [babashka.impl.common :as common] [borkdude.graal.locking :as locking] [clojure.core :as c] @@ -121,6 +121,22 @@ ;;;; End agents +;;;; STM + +(defn -run-in-transaction [f] + (clojure.lang.LockingTransaction/runInTransaction f)) + +(defmacro sync + "transaction-flags => TBD, pass nil for now + Runs the exprs (in an implicit do) in a transaction that encompasses + exprs and any nested calls. Starts a transaction if none is already + running on this thread. Any uncaught exception will abort the + transaction and flow out of sync. The exprs may be run more than + once, but any effects on Refs will be atomic." + {:added "1.0"} + [_flags-ignored-for-now & body] + `(clojure.core/-run-in-transaction (fn [] ~@body))) + (def core-extras {;; agents 'agent (copy-core-var agent) @@ -161,6 +177,13 @@ '*math-context* math-context 'with-precision (sci/copy-var with-precision clojure-core-ns) '-with-precision (sci/copy-var -with-precision clojure-core-ns) + ;; STM + 'alter (sci/copy-var alter clojure-core-ns) + 'dosync (sci/copy-var dosync clojure-core-ns) + '-run-in-transaction (sci/copy-var -run-in-transaction clojure-core-ns) + 'sync (sci/copy-var sync clojure-core-ns) + 'ref (sci/copy-var ref clojure-core-ns) + 'ref-set (sci/copy-var ref-set clojure-core-ns) ;;'*clojure-version* clojure-version-var ;;'clojure-version (sci/copy-var clojure-version clojure-core-ns) } From bda6c0f36e44425e10f9716ad1100e889634989f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 20:15:32 +0200 Subject: [PATCH 68/83] borkdude/deps.clj#46: fix passing JVM opts --- deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.clj b/deps.clj index 3e50b7b8..9817687b 160000 --- a/deps.clj +++ b/deps.clj @@ -1 +1 @@ -Subproject commit 3e50b7b8f04a1463bec31a973d08e76077f26e4f +Subproject commit 9817687b0ee3eacc2b35a69a6381d0a0b446c06e From 6e86e6901015ee9e92b0ba10ad9e8d5ebe123bc6 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 20:19:44 +0200 Subject: [PATCH 69/83] minor [skip ci] --- deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.clj b/deps.clj index 9817687b..4607b9bd 160000 --- a/deps.clj +++ b/deps.clj @@ -1 +1 @@ -Subproject commit 9817687b0ee3eacc2b35a69a6381d0a0b446c06e +Subproject commit 4607b9bdc596ea6346c9c144cc2958ff21f84de2 From 12d6afc88517427834cd29a696498fbcaf541fbf Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 9 Jun 2021 22:47:17 +0200 Subject: [PATCH 70/83] STM: add commute --- src/babashka/impl/clojure/core.clj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/babashka/impl/clojure/core.clj b/src/babashka/impl/clojure/core.clj index 62731797..a7183ad6 100644 --- a/src/babashka/impl/clojure/core.clj +++ b/src/babashka/impl/clojure/core.clj @@ -179,6 +179,7 @@ '-with-precision (sci/copy-var -with-precision clojure-core-ns) ;; STM 'alter (sci/copy-var alter clojure-core-ns) + 'commute (sci/copy-var commute clojure-core-ns) 'dosync (sci/copy-var dosync clojure-core-ns) '-run-in-transaction (sci/copy-var -run-in-transaction clojure-core-ns) 'sync (sci/copy-var sync clojure-core-ns) From 732d2b5a8b7af79972521d45f3587701340a5f05 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 10 Jun 2021 12:04:23 +0200 Subject: [PATCH 71/83] Allow .notify / .wait interop call #879 --- src/babashka/impl/classes.clj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index 81522456..fae96345 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -406,10 +406,14 @@ :let [class-name (str c)]] {:name class-name :allPublicFields true})) + instance-checks (vec (for [c (sort (:instance-checks classes)) + :let [class-name (str c)]] + ;; don't include any methods + {:name class-name})) custom-entries (for [[c v] (:custom classes) :let [class-name (str c)]] (assoc v :name class-name)) - all-entries (concat entries constructors methods fields custom-entries)] + all-entries (concat entries constructors methods fields instance-checks custom-entries)] all-entries)) (defn generate-reflection-file From 6e4044c623894244315ac5b25a2c3deb1627fd4a Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 10 Jun 2021 12:10:47 +0200 Subject: [PATCH 72/83] Async is not optional --- script/uberjar | 1 - 1 file changed, 1 deletion(-) diff --git a/script/uberjar b/script/uberjar index 8a2bb9a6..7974b935 100755 --- a/script/uberjar +++ b/script/uberjar @@ -15,7 +15,6 @@ then # Remove all the default features, unless explicitly set to true: export BABASHKA_FEATURE_XML="${BABASHKA_FEATURE_XML:-false}" export BABASHKA_FEATURE_YAML="${BABASHKA_FEATURE_YAML:-false}" - export BABASHKA_FEATURE_CORE_ASYNC="${BABASHKA_FEATURE_CORE_ASYNC:-false}" export BABASHKA_FEATURE_CSV="${BABASHKA_FEATURE_CSV:-false}" export BABAHSKA_FEATURE_TRANSIT="${BABAHSKA_FEATURE_TRANSIT:-false}" export BABASHKA_FEATURE_JAVA_TIME="${BABASHKA_FEATURE_JAVA_TIME:-false}" From 637f0bb7577a6278413072607c3917732b5a3bae Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 10 Jun 2021 12:21:38 +0200 Subject: [PATCH 73/83] CHANGELOG [skip ci] --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98039cf7..b7a0c28b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ For a list of breaking changes, check [here](#breaking-changes). +## 0.4.5 + +Babashka proper: + +- Add `java.net.InetSocketAddress` +- Add support for slingshot [#675](https://github.com/babashka/babashka/issues/675) +- Add STM facilities (`dosync`, `ref`, etc.) +- Fix `.wait`, `.notify` interop on arbitrary classes + +Deps.clj (using in `clojure` invocations): + +- Fix JVM option parsing [#46](https://github.com/borkdude/deps.clj/issues/46) + ## 0.4.4 Babashka proper: From 1a4c627702ae84ad5bc322779f126cd077da4c25 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 10 Jun 2021 12:21:45 +0200 Subject: [PATCH 74/83] v0.4.5 --- resources/BABASHKA_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/BABASHKA_VERSION b/resources/BABASHKA_VERSION index 416fd598..c8a5397f 100644 --- a/resources/BABASHKA_VERSION +++ b/resources/BABASHKA_VERSION @@ -1 +1 @@ -0.4.5-SNAPSHOT \ No newline at end of file +0.4.5 \ No newline at end of file From d382eb9fc926cb9fa599b4c0593db45a78c35c56 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 10 Jun 2021 12:37:16 +0200 Subject: [PATCH 75/83] Version bump --- CHANGELOG.md | 2 ++ resources/BABASHKA_RELEASED_VERSION | 2 +- resources/BABASHKA_VERSION | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a0c28b..4194d579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ Deps.clj (using in `clojure` invocations): - Fix JVM option parsing [#46](https://github.com/borkdude/deps.clj/issues/46) +Sci: various minor performance improvements. + ## 0.4.4 Babashka proper: diff --git a/resources/BABASHKA_RELEASED_VERSION b/resources/BABASHKA_RELEASED_VERSION index b300caa3..c8a5397f 100644 --- a/resources/BABASHKA_RELEASED_VERSION +++ b/resources/BABASHKA_RELEASED_VERSION @@ -1 +1 @@ -0.4.4 \ No newline at end of file +0.4.5 \ No newline at end of file diff --git a/resources/BABASHKA_VERSION b/resources/BABASHKA_VERSION index c8a5397f..daf22b08 100644 --- a/resources/BABASHKA_VERSION +++ b/resources/BABASHKA_VERSION @@ -1 +1 @@ -0.4.5 \ No newline at end of file +0.4.6-SNAPSHOT \ No newline at end of file From 4492db289ea830096a93c5dc69c18b276524bc6d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 10 Jun 2021 12:38:35 +0200 Subject: [PATCH 76/83] CHANGELOG [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4194d579..031fe499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Babashka proper: - Add STM facilities (`dosync`, `ref`, etc.) - Fix `.wait`, `.notify` interop on arbitrary classes -Deps.clj (using in `clojure` invocations): +Deps.clj (used for resolving deps and `clojure` invocations): - Fix JVM option parsing [#46](https://github.com/borkdude/deps.clj/issues/46) From 35103f40ef113c5528dd74e3a547a6020ecf449f Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 13 Jun 2021 21:53:07 +0200 Subject: [PATCH 77/83] Upgrade to graal 21.1, fixes #884 (#885) --- .circleci/config.yml | 50 ++++++++++++------------ .github/workflows/build.yml | 72 +++++++++++++++++------------------ Dockerfile | 8 ++-- appveyor.yml | 4 +- doc/build.md | 8 ++-- doc/dev.md | 2 +- script/bump_graal_version.clj | 4 +- test/babashka/main_test.clj | 9 +++++ 8 files changed, 83 insertions(+), 74 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ad653a42..53356bc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,7 +76,7 @@ jobs: working_directory: ~/repo environment: LEIN_ROOT: "true" - GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.0.0 + GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.1.0 BABASHKA_PLATFORM: linux # used in release script BABASHKA_TEST_ENV: native BABASHKA_XMX: "-J-Xmx6500m" @@ -110,9 +110,9 @@ jobs: name: Download GraalVM command: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-amd64-21.1.0.tar.gz fi - run: name: Build binary @@ -136,7 +136,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-21.0.0 + - ~/graalvm-ce-java11-21.1.0 key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release @@ -151,7 +151,7 @@ jobs: working_directory: ~/repo environment: LEIN_ROOT: "true" - GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.0.0 + GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.1.0 BABASHKA_PLATFORM: linux # used in release script BABASHKA_TEST_ENV: native BABASHKA_STATIC: "true" @@ -198,9 +198,9 @@ jobs: name: Download GraalVM command: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-amd64-21.1.0.tar.gz fi - run: name: Build binary @@ -224,7 +224,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-21.0.0 + - ~/graalvm-ce-java11-21.1.0 key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release @@ -241,7 +241,7 @@ jobs: working_directory: ~/repo environment: LEIN_ROOT: "true" - GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.0.0 + GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.1.0 BABASHKA_PLATFORM: linux # used in release script BABASHKA_ARCH: aarch64 BABASHKA_TEST_ENV: native @@ -287,9 +287,9 @@ jobs: name: Download GraalVM command: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-aarch64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-aarch64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-aarch64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-aarch64-21.1.0.tar.gz fi - run: name: Build binary @@ -313,7 +313,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-21.0.0 + - ~/graalvm-ce-java11-21.1.0 key: linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release @@ -330,7 +330,7 @@ jobs: working_directory: ~/repo environment: LEIN_ROOT: "true" - GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.0.0 + GRAALVM_HOME: /home/circleci/graalvm-ce-java11-21.1.0 BABASHKA_PLATFORM: linux # used in release script BABASHKA_ARCH: aarch64 BABASHKA_TEST_ENV: native @@ -378,9 +378,9 @@ jobs: name: Download GraalVM command: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-aarch64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-aarch64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-aarch64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-aarch64-21.1.0.tar.gz fi - run: name: Build binary @@ -404,7 +404,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-21.0.0 + - ~/graalvm-ce-java11-21.1.0 key: linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release @@ -418,7 +418,7 @@ jobs: xcode: "12.0.0" environment: MACOSX_DEPLOYMENT_TARGET: 10.13 # 10.12 is EOL - GRAALVM_HOME: /Users/distiller/graalvm-ce-java11-21.0.0/Contents/Home + GRAALVM_HOME: /Users/distiller/graalvm-ce-java11-21.1.0/Contents/Home BABASHKA_PLATFORM: macos # used in release script BABASHKA_TEST_ENV: native BABASHKA_XMX: "-J-Xmx6500m" @@ -446,9 +446,9 @@ jobs: command: | cd ~ ls -la - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-darwin-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-darwin-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-darwin-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-darwin-amd64-21.1.0.tar.gz fi - run: name: Build binary @@ -470,7 +470,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-21.0.0 + - ~/graalvm-ce-java11-21.1.0 key: mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52cef161..c93c1ac4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,17 +45,17 @@ jobs: uses: actions/cache@v1 id: cache-graalvm with: - path: ~/graalvm-ce-java11-21.0.0 - key: ${{ runner.os }}-graalvm-21.0.0 + path: ~/graalvm-ce-java11-21.1.0 + key: ${{ runner.os }}-graalvm-21.1.0 restore-keys: | - ${{ runner.os }}-graalvm-21.0.0 + ${{ runner.os }}-graalvm-21.1.0 - name: Download GraalVM run: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-amd64-21.1.0.tar.gz fi - name: Fetch deps @@ -65,18 +65,18 @@ jobs: - name: Run tests run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" script/test - name: Test libraries run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" sudo script/install-clojure script/run_lib_tests - name: Build uberjar run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" script/uberjar - name: Babashka version @@ -133,17 +133,17 @@ jobs: uses: actions/cache@v1 id: cache-graalvm with: - path: ~/graalvm-ce-java11-21.0.0 - key: ${{ runner.os }}-graalvm-21.0.0 + path: ~/graalvm-ce-java11-21.1.0 + key: ${{ runner.os }}-graalvm-21.1.0 restore-keys: | - ${{ runner.os }}-graalvm-21.0.0 + ${{ runner.os }}-graalvm-21.1.0 - name: Download GraalVM run: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-amd64-21.1.0.tar.gz fi - name: Babashka version @@ -156,13 +156,13 @@ jobs: run: | export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar export BABASHKA_XMX="-J-Xmx6g" - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" cp babashka-${{ steps.babashka-version.outputs.version }}-reflection.json reflection.json script/compile - name: Test binary run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" BABASHKA_TEST_ENV=native script/test - name: Install clojure @@ -171,7 +171,7 @@ jobs: - name: Test libraries run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" BABASHKA_TEST_ENV=native script/run_lib_tests - name: Upload artifact @@ -214,17 +214,17 @@ jobs: uses: actions/cache@v1 id: cache-graalvm with: - path: ~/graalvm-ce-java11-21.0.0 - key: ${{ runner.os }}-graalvm-21.0.0 + path: ~/graalvm-ce-java11-21.1.0 + key: ${{ runner.os }}-graalvm-21.1.0 restore-keys: | - ${{ runner.os }}-graalvm-21.0.0 + ${{ runner.os }}-graalvm-21.1.0 - name: Download GraalVM run: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-linux-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-linux-amd64-21.1.0.tar.gz fi - name: Babashka version @@ -237,7 +237,7 @@ jobs: run: | export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar export BABASHKA_XMX="-J-Xmx6g" - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" export BABASHKA_STATIC=true cp babashka-${{ steps.babashka-version.outputs.version }}-reflection.json reflection.json script/compile @@ -245,7 +245,7 @@ jobs: - name: Test binary run: | ./bb '(+ 1 2 3)' - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" BABASHKA_TEST_ENV=native script/test - name: Install clojure @@ -254,7 +254,7 @@ jobs: - name: Test libraries run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0" BABASHKA_TEST_ENV=native script/run_lib_tests - name: Upload artifact @@ -288,17 +288,17 @@ jobs: uses: actions/cache@v1 id: cache-graalvm with: - path: ~/graalvm-ce-java11-21.0.0 - key: ${{ runner.os }}-graalvm-21.0.0 + path: ~/graalvm-ce-java11-21.1.0 + key: ${{ runner.os }}-graalvm-21.1.0 restore-keys: | - ${{ runner.os }}-graalvm-21.0.0 + ${{ runner.os }}-graalvm-21.1.0 - name: Download GraalVM run: | cd ~ - if ! [ -d graalvm-ce-java11-21.0.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-darwin-amd64-21.0.0.tar.gz - tar xzf graalvm-ce-java11-darwin-amd64-21.0.0.tar.gz + if ! [ -d graalvm-ce-java11-21.1.0 ]; then + curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-darwin-amd64-21.1.0.tar.gz + tar xzf graalvm-ce-java11-darwin-amd64-21.1.0.tar.gz fi - name: Babashka version @@ -311,19 +311,19 @@ jobs: run: | export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar export BABASHKA_XMX="-J-Xmx6g" - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0/Contents/Home" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0/Contents/Home" cp babashka-${{ steps.babashka-version.outputs.version }}-reflection.json reflection.json script/compile - name: Test binary run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0/Contents/Home" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0/Contents/Home" sudo script/install-leiningen BABASHKA_TEST_ENV=native script/test - name: Test libraries run: | - export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.0.0/Contents/Home" + export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0/Contents/Home" sudo script/install-clojure BABASHKA_TEST_ENV=native script/run_lib_tests diff --git a/Dockerfile b/Dockerfile index ba680a5a..a56bbafc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,13 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt update RUN apt install --no-install-recommends -yy curl unzip build-essential zlib1g-dev sudo WORKDIR "/opt" -RUN curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-linux-amd64-21.0.0.tar.gz -RUN tar -xzf graalvm-ce-java11-linux-amd64-21.0.0.tar.gz +RUN curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz +RUN tar -xzf graalvm-ce-java11-linux-amd64-21.1.0.tar.gz ARG BABASHKA_XMX="-J-Xmx4500m" -ENV GRAALVM_HOME="/opt/graalvm-ce-java11-21.0.0" -ENV JAVA_HOME="/opt/graalvm-ce-java11-21.0.0/bin" +ENV GRAALVM_HOME="/opt/graalvm-ce-java11-21.1.0" +ENV JAVA_HOME="/opt/graalvm-ce-java11-21.1.0/bin" ENV PATH="$JAVA_HOME:$PATH" ENV BABASHKA_XMX=$BABASHKA_XMX diff --git a/appveyor.yml b/appveyor.yml index 3fb7e31e..fe2ebb38 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ image: Visual Studio 2017 clone_folder: C:\projects\babashka environment: - GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-21.0.0 + GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-21.1.0 BABASHKA_XMX: "-J-Xmx5g" cache: @@ -44,7 +44,7 @@ build_script: - cmd: >- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" - powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0/graalvm-ce-java11-windows-amd64-21.0.0.zip', 'graalvm.zip') }" + powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-windows-amd64-21.1.0.zip', 'graalvm.zip') }" powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }" diff --git a/doc/build.md b/doc/build.md index 78a2da8f..c27082d5 100644 --- a/doc/build.md +++ b/doc/build.md @@ -3,24 +3,24 @@ ## Prerequisites - Install [lein](https://leiningen.org/) for producing uberjars -- Download [GraalVM](https://www.graalvm.org/downloads/). Currently we use *java11-21.0.0*. +- Download [GraalVM](https://www.graalvm.org/downloads/). Currently we use *java11-21.1.0*. - For Windows, installing Visual Studio 2019 with the "Desktop development with C++" workload is recommended. - Set `$GRAALVM_HOME` to the GraalVM distribution directory. On macOS this can look like: ``` shell - export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-21.0.0/Contents/Home + export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-21.1.0/Contents/Home ``` On linux: ``` shell - export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-21.0.0 + export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-21.1.0 ``` On Windows, from the [Visual Studio 2019 x64 Native Tools Command Prompt](https://github.com/oracle/graal/issues/2116#issuecomment-590470806) or `cmd.exe` (not Powershell): ``` - set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-java11-21.0.0 + set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-java11-21.1.0 ``` If you are not running from the x64 Native Tools Command Prompt, you will need to set additional environment variables using: ``` diff --git a/doc/dev.md b/doc/dev.md index 1c5f3c6b..4602aa5e 100644 --- a/doc/dev.md +++ b/doc/dev.md @@ -1,6 +1,6 @@ # Developing Babashka -You need [lein](https://leiningen.org/) for running JVM tests and/or producing uberjars. For building binaries you need GraalVM. Currently we use java11-21.0.0. +You need [lein](https://leiningen.org/) for running JVM tests and/or producing uberjars. For building binaries you need GraalVM. Currently we use java11-21.1.0. ## Clone repository diff --git a/script/bump_graal_version.clj b/script/bump_graal_version.clj index e448d42f..786d415a 100755 --- a/script/bump_graal_version.clj +++ b/script/bump_graal_version.clj @@ -51,9 +51,9 @@ ;; OR ;; ;; We could have them as environment variables -(def current-graal-version "20.2.0") +(def current-graal-version "21.0.0") (def current-java-version "java11") -(def valid-graal-bumps ["19.3.2" "20.1.0" "20.2.0" "20.3.0" "21.0.0"]) +(def valid-graal-bumps ["19.3.2" "20.1.0" "20.2.0" "20.3.0" "21.0.0" "21.1.0"]) (def valid-java-bumps ["java8" "java11"]) (def cl-options diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 2103a9e9..8104e8e7 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -646,6 +646,15 @@ true"))) (bb nil "-e" "(.get (.command (.info (java.lang.ProcessHandle/current))))") "bb")))) +(deftest interop-concurrency-test + (is (= ["true" 3] (last (bb nil "-e" + " +(def f (fn [_] + [(String/valueOf true) + (.length \"foo\")])) + +(vec (pmap f (map str (range 10000))))"))))) + ;;;; Scratch (comment From 0dc4c59794eb213ce43bb4aa5c2864221b776e37 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 13 Jun 2021 21:54:54 +0200 Subject: [PATCH 78/83] v0.4.6 --- CHANGELOG.md | 4 ++++ resources/BABASHKA_VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 031fe499..0a5bcf6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ For a list of breaking changes, check [here](#breaking-changes). +## 0.4.6 + +- Upgrade to GraalVM 21.1, fixes [#884](https://github.com/babashka/babashka/issues/884) + ## 0.4.5 Babashka proper: diff --git a/resources/BABASHKA_VERSION b/resources/BABASHKA_VERSION index daf22b08..c0a1ac19 100644 --- a/resources/BABASHKA_VERSION +++ b/resources/BABASHKA_VERSION @@ -1 +1 @@ -0.4.6-SNAPSHOT \ No newline at end of file +0.4.6 \ No newline at end of file From 535b70093d769fd8ff33e4a2ef4d9b26afdc9de2 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 13 Jun 2021 22:26:46 +0200 Subject: [PATCH 79/83] Version bump --- resources/BABASHKA_RELEASED_VERSION | 2 +- resources/BABASHKA_VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/BABASHKA_RELEASED_VERSION b/resources/BABASHKA_RELEASED_VERSION index c8a5397f..c0a1ac19 100644 --- a/resources/BABASHKA_RELEASED_VERSION +++ b/resources/BABASHKA_RELEASED_VERSION @@ -1 +1 @@ -0.4.5 \ No newline at end of file +0.4.6 \ No newline at end of file diff --git a/resources/BABASHKA_VERSION b/resources/BABASHKA_VERSION index c0a1ac19..5b151cef 100644 --- a/resources/BABASHKA_VERSION +++ b/resources/BABASHKA_VERSION @@ -1 +1 @@ -0.4.6 \ No newline at end of file +0.4.7-SNAPSHOT \ No newline at end of file From f519c358233cc874aadad896a94ea293cc7c6c8d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 13 Jun 2021 22:52:32 +0200 Subject: [PATCH 80/83] doc [skip ci] --- doc/dev.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev.md b/doc/dev.md index 4602aa5e..d9e4e15c 100644 --- a/doc/dev.md +++ b/doc/dev.md @@ -114,6 +114,8 @@ Some of these design decisions were formed in [these discussions](https://github Keep notes here about how adding libraries and classes to Babashka affects the binary size. We're registering the size of the macOS binary (as built on CircleCI). +2021/06/13 Upgrading from GraalvM 21.0 to 21.1 added roughly 3mb. Issue [here](https://github.com/oracle/graal/issues/3280#issuecomment-846402115). + 2020/10/30 Without httpkit client+server: 68113436. With: 69503316 = 1390kb added. 2020/05/01 Removed `next.jdbc` and postgres JDBC driver: 48304980 From 90ac55d588bc9c08f623ae7f454b552fa5de5cec Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 16 Jun 2021 11:01:17 +0200 Subject: [PATCH 81/83] Start porting Windows tests (#235) (#887) --- appveyor.yml | 22 +++++++++++----------- project.clj | 1 + script/test.bat | 11 +++++++++++ test/babashka/impl/nrepl_server_test.clj | 2 +- test/babashka/impl/repl_test.clj | 21 ++++++++++++--------- test/babashka/main_test.clj | 13 +++++++------ test/babashka/test_utils.clj | 9 ++++++++- 7 files changed, 51 insertions(+), 28 deletions(-) create mode 100755 script/test.bat diff --git a/appveyor.yml b/appveyor.yml index fe2ebb38..b5e535ed 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,7 @@ clone_folder: C:\projects\babashka environment: GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-21.1.0 + JAVA_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-21.1.0 BABASHKA_XMX: "-J-Xmx5g" cache: @@ -30,24 +31,26 @@ clone_script: - cmd: git submodule update --init --recursive build_script: +- cmd: >- + powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-windows-amd64-21.1.0.zip', 'graalvm.zip') }" + + powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }" + - cmd: >- powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein.bat', 'lein.bat')" call lein self-install -# set CLJ_KONDO_TEST_ENV=jvm +- cmd: >- + set BABASHKA_TEST_ENV=jvm -# call script/test.bat + call script/test.bat # see https://github.com/quarkusio/quarkus/pull/7663 - cmd: >- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" - powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-windows-amd64-21.1.0.zip', 'graalvm.zip') }" - - powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }" - call script/uberjar.bat call script/compile.bat @@ -62,12 +65,9 @@ build_script: bb release-artifact %zip% -# - cmd: >- -# lein clean + set BABASHKA_TEST_ENV=native -# set CLJ_KONDO_TEST_ENV=native - -# call script/test.bat + call script/test.bat artifacts: - path: babashka-*-windows-amd64.zip diff --git a/project.clj b/project.clj index 4170489b..86cf3710 100644 --- a/project.clj +++ b/project.clj @@ -14,6 +14,7 @@ ;; :java-source-paths ["sci/reflector/src-java"] :java-source-paths ["src-java"] :resource-paths ["resources" "sci/resources"] + :test-selectors {:windows :windows} :dependencies [[org.clojure/clojure "1.11.0-alpha1"] [borkdude/edamame "0.0.11"] [borkdude/graal.locking "0.0.2"] diff --git a/script/test.bat b/script/test.bat new file mode 100755 index 00000000..ba69e4ec --- /dev/null +++ b/script/test.bat @@ -0,0 +1,11 @@ +if "%GRAALVM_HOME%"=="" ( +echo Please set GRAALVM_HOME +exit /b +) + +echo "BABASHKA_TEST_ENV: %BABASHKA_TEST_ENV%" + +set JAVA_HOME=%GRAALVM_HOME% +set PATH=%GRAALVM_HOME%\bin;%PATH% + +call lein do clean, test :windows diff --git a/test/babashka/impl/nrepl_server_test.clj b/test/babashka/impl/nrepl_server_test.clj index 08dddee0..822fb802 100644 --- a/test/babashka/impl/nrepl_server_test.clj +++ b/test/babashka/impl/nrepl_server_test.clj @@ -180,7 +180,7 @@ "session" session "id" (new-id!)}) (dotimes [_ 3] (let [reply (read-reply in session @id)] - (is (= "Hello\n" (:out reply))))))))) + (is (= "Hello\n" (tu/normalize (:out reply)))))))))) (deftest nrepl-server-test (let [proc-state (atom nil) diff --git a/test/babashka/impl/repl_test.clj b/test/babashka/impl/repl_test.clj index d9cf7b70..a1bd730b 100644 --- a/test/babashka/impl/repl_test.clj +++ b/test/babashka/impl/repl_test.clj @@ -2,6 +2,7 @@ (:require [babashka.impl.pprint :refer [pprint-namespace]] [babashka.impl.repl :refer [start-repl!]] + [babashka.test-utils :as tu] [clojure.string :as str] [clojure.test :as t :refer [deftest is]] [sci.core :as sci] @@ -20,18 +21,20 @@ :namespaces {'clojure.pprint pprint-namespace}}))) (defn assert-repl [expr expected] - (is (str/includes? (sci/with-out-str - (sci/with-in-str (str expr "\n:repl/quit") - (repl!))) expected))) + (is (str/includes? (tu/normalize + (sci/with-out-str + (sci/with-in-str (str expr "\n:repl/quit") + (repl!)))) expected))) (defn assert-repl-error [expr expected] (is (str/includes? - (let [sw (java.io.StringWriter.)] - (sci/binding [sci/out (java.io.StringWriter.) - sci/err sw] - (sci/with-in-str (str expr "\n:repl/quit") - (repl!))) - (str sw)) expected))) + (tu/normalize + (let [sw (java.io.StringWriter.)] + (sci/binding [sci/out (java.io.StringWriter.) + sci/err sw] + (sci/with-in-str (str expr "\n:repl/quit") + (repl!))) + (str sw))) expected))) (deftest repl-test (assert-repl "1" "1") diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 8104e8e7..da3185f9 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -17,7 +17,7 @@ :eof nil} (apply test-utils/bb (when (some? input) (str input)) (map str args)))) -(deftest parse-opts-test +(deftest ^:windows parse-opts-test (is (= "1667" (:nrepl (main/parse-opts ["--nrepl-server"])))) (is (= "1666" @@ -132,7 +132,7 @@ (is (not-empty s))))) (deftest malformed-command-line-args-test - (is (thrown-with-msg? Exception #"File does not exist: non-existing\n" + (is (thrown-with-msg? Exception #"File does not exist: non-existing" (bb nil "-f" "non-existing")))) (deftest ssl-test @@ -178,10 +178,11 @@ name))))) (testing "print source from file on classpath" (is (= "(defn foo [x y]\n (+ x y))\n" - (bb nil - "-cp" dir - "-e" (format "(require '[clojure.repl :refer [source]] '[%s])" name) - "-e" (format "(with-out-str (source %s/foo))" name))))))) + (test-utils/normalize + (bb nil + "-cp" dir + "-e" (format "(require '[clojure.repl :refer [source]] '[%s])" name) + "-e" (format "(with-out-str (source %s/foo))" name)))))))) (deftest eval-test (is (= "120\n" (test-utils/bb nil "(eval '(do (defn foo [x y] (+ x y)) diff --git a/test/babashka/test_utils.clj b/test/babashka/test_utils.clj index c3f18752..79cd85c2 100644 --- a/test/babashka/test_utils.clj +++ b/test/babashka/test_utils.clj @@ -6,12 +6,19 @@ [babashka.main :as main] [babashka.process :as p] [clojure.edn :as edn] + [clojure.string :as str] [clojure.test :as test :refer [*report-counters*]] [sci.core :as sci] [sci.impl.vars :as vars])) (set! *warn-on-reflection* true) + +(defn normalize [s] + (if main/windows? + (str/replace s "\r\n" "\n") + s)) + (def ^:dynamic *bb-edn-path* nil) (defmethod clojure.test/report :begin-test-var [m] @@ -55,7 +62,7 @@ (with-in-str input-or-opts (apply main/main args)) (apply main/main args)))] (if (zero? res) - (str os) + (normalize (str os)) (do (println (str os)) (throw (ex-info (str es) From 63619fd66b933baca60bed52a7784d8fa7707c47 Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 16 Jun 2021 10:40:02 -0400 Subject: [PATCH 82/83] add windows selector to a couple of tests (#235) (#888) --- test/babashka/main_test.clj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index da3185f9..a56bfc87 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -52,17 +52,17 @@ (is (= '("-e" "1") (bb nil "-e" "*command-line-args*" "--" "-e" "1"))) (let [v (bb nil "--describe")] (is (:babashka/version v)) - (is (:feature/xml v))) - ) + (is (:feature/xml v)))) -(deftest version-test + +(deftest ^:windows version-test (is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT"))) (is (main/satisfies-min-version? "0.1.0")) (is (main/satisfies-min-version? "0.1.0-SNAPSHOT")) (is (not (main/satisfies-min-version? "300.0.0"))) (is (not (main/satisfies-min-version? "300.0.0-SNAPSHOT")))) -(deftest print-error-test +(deftest ^:windows print-error-test (is (thrown-with-msg? Exception #"java.lang.NullPointerException" (bb nil "(subs nil 0 0)")))) @@ -131,7 +131,7 @@ (doseq [s res] (is (not-empty s))))) -(deftest malformed-command-line-args-test +(deftest ^:windows malformed-command-line-args-test (is (thrown-with-msg? Exception #"File does not exist: non-existing" (bb nil "-f" "non-existing")))) From 7d696f0dc5f7c29f88227531cee1bbd176e38010 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 16 Jun 2021 17:37:43 +0200 Subject: [PATCH 83/83] deps.clj [skip ci] --- deps.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.clj b/deps.clj index 4607b9bd..520b6b05 160000 --- a/deps.clj +++ b/deps.clj @@ -1 +1 @@ -Subproject commit 4607b9bdc596ea6346c9c144cc2958ff21f84de2 +Subproject commit 520b6b053b7bdfe46990ab82220a2d13f79f9772