babashka/test/babashka/pod_test.clj
Bob 16911a54f0
add more windows testing (#902)
- add default test selector to skip "windows only" tests
- in cases where the differences between *nix shell and windows shell
  make the test very messy, add a separate "windows only" test
- make more tests work on Windows
2021-06-24 22:34:57 +02:00

29 lines
1.3 KiB
Clojure

(ns babashka.pod-test
(:require [babashka.main :as main]
[babashka.test-utils :as tu]
[clojure.edn :as edn]
[clojure.test :as t :refer [deftest is]]))
(deftest pod-test
(if (= "true" (System/getenv "BABASHKA_POD_TEST"))
(let [native? tu/native?
windows? main/windows?
sw (java.io.StringWriter.)
res (apply tu/bb {:err sw}
(cond-> ["-f" "test-resources/pod.clj"]
native?
(conj "--native")
windows?
(conj "--windows")))
err (str sw)]
(is (= "6\n1\n2\n3\n4\n5\n6\n7\n8\n9\n\"Illegal arguments / {:args (1 2 3)}\"\n(\"hello\" \"print\" \"this\" \"debugging\" \"message\")\ntrue\n" res))
(when-not tu/native?
(is (= "(\"hello\" \"print\" \"this\" \"error\")\n" (tu/normalize err))))
(is (= {:a 1 :b 2}
(edn/read-string
(apply tu/bb nil (cond-> ["-f" "test-resources/pod.clj" "--json"]
native?
(conj "--native")
windows?
(conj "--windows")))))))
(println "Skipping pod test because BABASHKA_POD_TEST isn't set to true.")))