* make tests run on windows as the default - change from selecting tests to run to selecting tests to skip (remove all :windows tags, add :skip-windows tag to tests that don't currently work on windows) - handfuls of calls to `normalize` and `escape-file-paths` to handle platform differences - split `task-test` to make most of the tests run on windows, and exclude just a couple of Unix-y tests * make a binding name clearer * skip nrepl-server-test on Windows - test fails on CI, so disabling it for now * unset bb environment vars after running tests * unset bb environment var after running release-artifact BABASHKA_EDN being set can interfere with some tests, so unset it before running the native tests * skip uberjar test on Windows uberjar-test's 'throw on empty classpath' test failing on Windows native (but passes on JVM) - skip it for now
35 lines
967 B
Clojure
35 lines
967 B
Clojure
(ns babashka.async-test
|
|
(:require
|
|
[babashka.test-utils :as test-utils]
|
|
[clojure.edn :as edn]
|
|
[clojure.test :as t :refer [deftest is]]))
|
|
|
|
(deftest ^:skip-windows alts!!-test
|
|
(is (= "process 2\n" (test-utils/bb nil "
|
|
(defn async-command [& args]
|
|
(async/thread (apply shell/sh \"bash\" \"-c\" args)))
|
|
|
|
(-> (async/alts!! [(async-command \"sleep 2 && echo process 1\")
|
|
(async-command \"sleep 1 && echo process 2\")])
|
|
first :out str/trim println)"))))
|
|
|
|
(deftest go-test
|
|
(is (number? (edn/read-string (test-utils/bb nil "
|
|
(defn calculation-go []
|
|
(async/go
|
|
;; wait for some stuff
|
|
(rand-int 1000)))
|
|
|
|
(defn get-result-go []
|
|
(async/go
|
|
(->>
|
|
(repeatedly 10 calculation-go)
|
|
(map async/<!)
|
|
(reduce +))))
|
|
|
|
(async/<!! (get-result-go))")))))
|
|
|
|
(deftest binding-conveyance-test
|
|
(is (number? (edn/read-string (test-utils/bb nil "
|
|
(def ^:dynamic x 0)
|
|
(binding [x 10] (async/<!! (async/thread x)))")))))
|