- remove zero size tolerance for overwriting uber-files (#1504)
- in tests, delete temp output files that would prevent overwrite - in tests, change 'non-empty' files to be empty files (since non-empty is no longer necessary) - in hato test, replace nghttp2 with httpbin, since httpbin uses http/2 by default now, and to benefit from httpbin 'flaky' test
This commit is contained in:
parent
3045cd226e
commit
5dc7763325
4 changed files with 13 additions and 13 deletions
|
|
@ -785,8 +785,7 @@ Use bb run --help to show this help output.
|
|||
and files that are empty/don't exist."
|
||||
[path]
|
||||
(or (= "jar" (fs/extension path))
|
||||
(not (fs/exists? path))
|
||||
(zero? (fs/size path))))
|
||||
(not (fs/exists? path))))
|
||||
|
||||
(def seen-urls (atom nil))
|
||||
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@
|
|||
|
||||
(deftest ^:integration test-http2
|
||||
(testing "can make an http2 request"
|
||||
(let [r (get "https://nghttp2.org/httpbin/get" {:as :json})]
|
||||
(let [r (get "https://httpbin.org/get" {:as :json})]
|
||||
(is (= :http-2 (:version r))))))
|
||||
|
||||
(deftest custom-middleware
|
||||
|
|
|
|||
|
|
@ -484,14 +484,14 @@
|
|||
(deftest uberscript-test
|
||||
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
|
||||
(.deleteOnExit tmp-file)
|
||||
(.delete tmp-file) ; prevent overwrite failure
|
||||
(is (empty? (bb nil "--uberscript" (test-utils/escape-file-paths (.getPath tmp-file)) "-e" "(System/exit 1)")))
|
||||
(is (= "(System/exit 1)" (slurp tmp-file)))))
|
||||
|
||||
(deftest uberscript-overwrite-test
|
||||
(testing "trying to make uberscript overwrite a non-empty, non-jar file fails"
|
||||
(testing "trying to make uberscript overwrite a non-jar file fails"
|
||||
(let [tmp-file (java.io.File/createTempFile "uberscript_overwrite" ".clj")]
|
||||
(.deleteOnExit tmp-file)
|
||||
(spit (.getPath tmp-file) "this isn't empty")
|
||||
(is (thrown-with-msg? Exception #"Overwrite prohibited."
|
||||
(test-utils/bb nil "--uberscript" (test-utils/escape-file-paths (.getPath tmp-file)) "-e" "(println 123)"))))))
|
||||
|
||||
|
|
@ -516,11 +516,10 @@
|
|||
(test-utils/bb nil "--uberjar" (test-utils/escape-file-paths path) "-m" "my.main-main")
|
||||
; execute uberjar to confirm that the file is overwritten
|
||||
(is (= "(\"42\")\n" (test-utils/bb nil "--prn" "--jar" (test-utils/escape-file-paths path) "42")))))
|
||||
(testing "trying to make uberjar overwrite a non-empty, non-jar file is not allowed"
|
||||
(testing "trying to make uberjar overwrite a non-jar file is not allowed"
|
||||
(let [tmp-file (java.io.File/createTempFile "oops_all_source" ".clj")
|
||||
path (.getPath tmp-file)]
|
||||
(.deleteOnExit tmp-file)
|
||||
(spit path "accidentally a source file")
|
||||
(is (thrown-with-msg? Exception #"Overwrite prohibited."
|
||||
(test-utils/bb nil "--uberjar" (test-utils/escape-file-paths path) "-m" "my.main-main")))))))
|
||||
|
||||
|
|
|
|||
|
|
@ -4,17 +4,20 @@
|
|||
[clojure.string :as str]
|
||||
[clojure.test :as t :refer [deftest is]]))
|
||||
|
||||
(defn deleted-temp-file []
|
||||
(doto (java.io.File/createTempFile "uberscript" ".clj")
|
||||
.deleteOnExit
|
||||
.delete)) ; delete file to prevent overwrite failure
|
||||
|
||||
(deftest basic-test
|
||||
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
|
||||
(.deleteOnExit tmp-file)
|
||||
(let [tmp-file (deleted-temp-file)]
|
||||
(is (empty? (tu/bb nil "--prn" "--classpath" "test-resources/babashka/src_for_classpath_test" "uberscript" (.getPath tmp-file) "-m" "my.main")))
|
||||
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
|
||||
(tu/bb nil "--prn" "--file" (.getPath tmp-file) "1" "2" "3" "4")))))
|
||||
|
||||
(when-not (= "aarch64" (System/getenv "BABASHKA_ARCH"))
|
||||
(deftest advanced-test
|
||||
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
|
||||
(.deleteOnExit tmp-file)
|
||||
(let [tmp-file (deleted-temp-file)]
|
||||
;; we test:
|
||||
;; order of namespaces
|
||||
;; reader error for ::a/foo is swallowed
|
||||
|
|
@ -25,8 +28,7 @@
|
|||
(tu/bb nil "--prn" "--file" (.getPath tmp-file) "1" "2" "3" "4"))))))
|
||||
|
||||
(deftest pods-test
|
||||
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
|
||||
(.deleteOnExit tmp-file)
|
||||
(let [tmp-file (deleted-temp-file)]
|
||||
(tu/with-config (pr-str '{:paths ["test-resources/babashka/uberscript/src"]
|
||||
:pods {org.babashka/go-sqlite3 {:version "0.1.0"}}})
|
||||
(is (empty? (tu/bb nil "--prn" "uberscript" (.getPath tmp-file) "-m" "my.main-pod")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue