From af6f94ef81712769b5cc053d04d45c9b96d78e30 Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 11 Jul 2021 18:00:14 -0400 Subject: [PATCH] run lib tests in Windows CI (#933) * run lib tests in Windows CI - add batch scripts for invoking tests - skip some tests on windows - tweak a couple tests to run on linux and windows * configure git to checkout with Windows line endings on Appveyor --- appveyor.yml | 3 +++ script/lib_tests/run_all_libtests.bat | 5 ++++ script/run_lib_tests.bat | 1 + .../lib_tests/babashka/run_all_libtests.clj | 24 ++++++++++++------- .../lib_tests/clojure/data/json_test.clj | 2 +- test-resources/lib_tests/selmer/core_test.clj | 3 +-- 6 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 script/lib_tests/run_all_libtests.bat create mode 100644 script/run_lib_tests.bat diff --git a/appveyor.yml b/appveyor.yml index 2650deff..cff66027 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,6 +17,7 @@ cache: - 'graalvm -> appveyor.yml' clone_script: +- cmd: git config --global core.autocrlf true - ps: >- if(-not $env:APPVEYOR_PULL_REQUEST_NUMBER) { git clone -q --branch=$env:APPVEYOR_REPO_BRANCH https://github.com/$env:APPVEYOR_REPO_NAME.git $env:APPVEYOR_BUILD_FOLDER @@ -71,6 +72,8 @@ build_script: call script/test.bat + call script/run_lib_tests.bat + artifacts: - path: babashka-*-windows-amd64.zip name: babashka diff --git a/script/lib_tests/run_all_libtests.bat b/script/lib_tests/run_all_libtests.bat new file mode 100644 index 00000000..015073a1 --- /dev/null +++ b/script/lib_tests/run_all_libtests.bat @@ -0,0 +1,5 @@ +if "%BABASHKA_TEST_ENV%" EQU "native" (set BB_CMD=.\bb) else (set BB_CMD=lein bb) + +for /f %%i in ('.\bb clojure -A:lib-tests -Spath') do set BABASHKA_CLASSPATH=%%i + +%BB_CMD% -cp "%BABASHKA_CLASSPATH%;test-resources/lib_tests" -f test-resources/lib_tests/babashka/run_all_libtests.clj %* diff --git a/script/run_lib_tests.bat b/script/run_lib_tests.bat new file mode 100644 index 00000000..003786b9 --- /dev/null +++ b/script/run_lib_tests.bat @@ -0,0 +1 @@ +call script/lib_tests/run_all_libtests.bat %* || exit /B 1 diff --git a/test-resources/lib_tests/babashka/run_all_libtests.clj b/test-resources/lib_tests/babashka/run_all_libtests.clj index 0a46f1bd..a9b11e6d 100644 --- a/test-resources/lib_tests/babashka/run_all_libtests.clj +++ b/test-resources/lib_tests/babashka/run_all_libtests.clj @@ -1,5 +1,6 @@ (ns babashka.run-all-libtests (:require [clojure.java.io :as io] + [clojure.string :as str] [clojure.test :as t])) (def ns-args (set (map symbol *command-line-args*))) @@ -19,6 +20,10 @@ (swap! status (fn [status] (merge-with + status (dissoc m :type)))))))) +(def windows? (-> (System/getProperty "os.name") + (str/lower-case) + (str/includes? "win"))) + ;;;; clj-http-lite (test-namespaces 'clj-http.lite.client-test) @@ -38,8 +43,8 @@ (prn (random-uuid)) ;;;; babashka.curl - -(test-namespaces 'babashka.curl-test) +; skip tests on Windows because of the :compressed thing +(when-not windows? (test-namespaces 'babashka.curl-test)) ;;;; cprop @@ -114,7 +119,8 @@ (require '[babashka.curl :as curl]) (spit "deps_test.clj" - (:body (curl/get "https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj"))) + (:body (curl/get "https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj" + (if windows? {:compressed false} {})))) (binding [*command-line-args* ["-Sdescribe"]] (load-file "deps_test.clj")) @@ -170,13 +176,13 @@ (test-namespaces 'httpkit.client-test) ;;;; babashka.process +(when-not windows? + ;; test built-in babashka.process + (test-namespaces 'babashka.process-test) -;; test built-in babashka.process -(test-namespaces 'babashka.process-test) - -;; test babashka.process from source -(require '[babashka.process] :reload) -(test-namespaces 'babashka.process-test) + ;; test babashka.process from source + (require '[babashka.process] :reload) + (test-namespaces 'babashka.process-test)) (test-namespaces 'core-match.core-tests) diff --git a/test-resources/lib_tests/clojure/data/json_test.clj b/test-resources/lib_tests/clojure/data/json_test.clj index 53984e46..9e905279 100644 --- a/test-resources/lib_tests/clojure/data/json_test.clj +++ b/test-resources/lib_tests/clojure/data/json_test.clj @@ -413,7 +413,7 @@ (is (= x (json/read-str (with-out-str (json/pprint x))))))) (deftest pretty-print-nonescaped-unicode - (is (= "\"\u1234\u4567\"\n" + (is (= (str "\"\u1234\u4567\"" (System/lineSeparator)) (with-out-str (json/pprint "\u1234\u4567" :escape-unicode false))))) diff --git a/test-resources/lib_tests/selmer/core_test.clj b/test-resources/lib_tests/selmer/core_test.clj index ddf65652..a2f35782 100644 --- a/test-resources/lib_tests/selmer/core_test.clj +++ b/test-resources/lib_tests/selmer/core_test.clj @@ -1048,7 +1048,7 @@ ;; (is (nil? *custom-resource-path*))) (deftest custom-resource-path-setting-url - (p/set-resource-path! (clojure.java.io/resource "templates/inheritance")) + (p/set-resource-path! "templates/inheritance") #_(is (string? *custom-resource-path*)) (is (= (fix-line-sep "Hello, World!\n") (render-file "foo.html" {:name "World"}))) (p/set-resource-path! nil)) @@ -1257,4 +1257,3 @@ "debug-value")) (testing "basic rendering escapes HTML" (is (str/includes? (basic-edn->html {:a "
"}) """))))
-