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)