Skip to content

Commit

Permalink
[#40] Catch up with 1.10.384
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Mar 22, 2021
1 parent 66e797b commit a301f47
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 57 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
- run:
name: Install Clojure
command: |
wget -nc https://download.clojure.org/install/linux-install-1.10.2.796.sh
chmod +x linux-install-1.10.2.796.sh
sudo ./linux-install-1.10.2.796.sh
wget -nc https://download.clojure.org/install/linux-install-1.10.3.814.sh
chmod +x linux-install-1.10.3.814.sh
sudo ./linux-install-1.10.3.814.sh
- run:
name: Run JVM tests
command: |
Expand Down Expand Up @@ -86,9 +86,9 @@ jobs:
- run:
name: Install Clojure
command: |
wget https://download.clojure.org/install/linux-install-1.10.2.796.sh
chmod +x linux-install-1.10.2.796.sh
sudo ./linux-install-1.10.2.796.sh
wget https://download.clojure.org/install/linux-install-1.10.3.814.sh
chmod +x linux-install-1.10.3.814.sh
sudo ./linux-install-1.10.3.814.sh
- run:
name: Install lsof
command: |
Expand Down
6 changes: 3 additions & 3 deletions .circleci/script/install-clojure
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
install_dir=${1:-/tmp/clojure}
mkdir -p "$install_dir"
cd /tmp
curl -O -sL https://download.clojure.org/install/clojure-tools-1.10.2.796.tar.gz
tar xzf clojure-tools-1.10.2.796.tar.gz
curl -O -sL https://download.clojure.org/install/clojure-tools-1.10.3.814.tar.gz
tar xzf clojure-tools-1.10.3.814.tar.gz
cd clojure-tools
clojure_lib_dir="$install_dir/lib/clojure"
mkdir -p "$clojure_lib_dir/libexec"
Expand All @@ -18,6 +18,6 @@ cp clojure "$install_dir/bin"
cp clj "$install_dir/bin"

cd /tmp
rm -rf clojure-tools-1.10.2.796.tar.gz
rm -rf clojure-tools-1.10.3.814.tar.gz
rm -rf clojure-tools
echo "Installed clojure to $install_dir/bin"
53 changes: 31 additions & 22 deletions deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(set! *warn-on-reflection* true)
(def path-separator (System/getProperty "path.separator"))

(def version "1.10.1.763")
(def version "1.10.3.814")
(def deps-clj-version "0.0.12-SNAPSHOT")

(defn warn [& strs]
Expand Down Expand Up @@ -104,6 +104,8 @@ clj-opts:
-Sthreads Set specific number of download threads
-Strace Write a trace.edn file that traces deps expansion
-- Stop parsing dep options and pass remaining arguments to clojure.main
--version Print the version to stdout and exit
-version Print the version to stdout and exit
The following non-standard options are available only in deps.clj:
Expand Down Expand Up @@ -301,6 +303,8 @@ For more info, see:
string-opt-keyword (get string-opts->keyword arg)]
(cond
(= "--" arg) (assoc acc :args (next command-line-args))
(or (= "-version" arg)
(= "--version" arg)) (assoc acc :version true)
(str/starts-with? arg "-M")
(assoc acc
:mode :main
Expand Down Expand Up @@ -347,17 +351,18 @@ For more info, see:
:else (assoc acc :args command-line-args)))
acc))
java-cmd
(let [java-cmd (which (if windows? "java.exe" "java"))]
(if (str/blank? java-cmd)
(let [java-home (System/getenv "JAVA_HOME")]
(if-not (str/blank? java-home)
(let [f (io/file java-home "bin" "java")]
(if (and (.exists f)
(.canExecute f))
(.getCanonicalPath f)
(or (System/getenv "JAVA_CMD")
(let [java-cmd (which (if windows? "java.exe" "java"))]
(if (str/blank? java-cmd)
(let [java-home (System/getenv "JAVA_HOME")]
(if-not (str/blank? java-home)
(let [f (io/file java-home "bin" "java")]
(if (and (.exists f)
(.canExecute f))
(.getCanonicalPath f)
(throw (Exception. "Couldn't find 'java'. Please set JAVA_HOME."))))
(throw (Exception. "Couldn't find 'java'. Please set JAVA_HOME."))))
(throw (Exception. "Couldn't find 'java'. Please set JAVA_HOME."))))
java-cmd))
java-cmd)))
clojure-file (-> (which "clojure") (io/file))
install-dir (when clojure-file
(with-open [reader (io/reader clojure-file)]
Expand Down Expand Up @@ -499,7 +504,8 @@ For more info, see:
(conj "--tree")))]
;; If stale, run make-classpath to refresh cached classpath
(when (and stale (not (or (:describe args)
(:help args))))
(:help args)
(:version args))))
(when (:verbose args)
(warn "Refreshing classpath"))
(let [res (shell-command (into clj-main-cmd
Expand All @@ -523,6 +529,8 @@ For more info, see:
:else (slurp (io/file cp-file)))]
(cond (:help args) (do (println help-text)
(*exit-fn* 0))
(:version args) (do (println "Clojure CLI version (deps.clj)" version)
(*exit-fn* 0))
(:prep args) (*exit-fn* 0)
(:pom args)
(shell-command (into clj-main-cmd
Expand Down Expand Up @@ -550,7 +558,8 @@ For more info, see:
(:command args)
(let [command (str/replace (:command args) "{{classpath}}" (str cp))
main-cache-opts (when (.exists (io/file main-file))
(slurp main-file))
(-> main-file slurp str/split-lines))
main-cache-opts (str/join " " main-cache-opts)
command (str/replace command "{{main-opts}}" (str main-cache-opts))
command (str/split command #"\s+")
command (into command (:args args))]
Expand All @@ -559,25 +568,25 @@ For more info, see:
(let [exec-args (when-let [aliases (:exec-aliases args)]
["--aliases" aliases])
jvm-cache-opts (when (.exists (io/file jvm-file))
(slurp jvm-file))
main-args (if exec?
(-> jvm-file slurp str/split-lines))
main-cache-opts (when (.exists (io/file main-file))
(-> main-file slurp str/split-lines))
main-opts (if exec?
(into ["-m" "clojure.run.exec"]
exec-args)
(some-> (when (.exists (io/file main-file))
(slurp main-file))
(str/split #"\s")))
main-cache-opts)
cp (if exec?
(str cp path-separator exec-cp)
cp)
main-args (concat [java-cmd]
proxy-settings
[jvm-cache-opts
(:jvm-opts args)
(str "-Dclojure.basis=" basis-file)
jvm-cache-opts
(:jvm-opts args)
[(str "-Dclojure.basis=" basis-file)
(str "-Dclojure.libfile=" libs-file)
"-classpath" cp
"clojure.main"]
main-args)
main-opts)
main-args (filterv some? main-args)
main-args (into main-args (:args args))]
(*process-fn* main-args)))))))
Expand Down
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
:aliases
{:test
{:extra-paths ["test"]
:main-opts ["-e" "(require,'[clojure.test,:as,t],'[borkdude.deps-test]),(t/run-tests,'borkdude.deps-test)"]}
:main-opts ["-e" "(require,'[clojure.test,:as,t],'[borkdude.deps-test]),(t/run-tests,'borkdude.deps-test)"]
:extra-deps {babashka/fs {:mvn/version "0.0.3"}}}
:exec-test
{:extra-paths ["test"]
:exec-fn borkdude.exec-test/exec-fn}}}
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:url "http://opensource.org/licenses/eclipse-1.0.php"}
:source-paths ["src"]
:resource-paths ["resources"]
:dependencies [[org.clojure/clojure "1.10.2"]]
:dependencies [[org.clojure/clojure "1.10.3"]]
:profiles {:uberjar {:global-vars {*assert* false}
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
"-Dclojure.spec.skip-macros=true"]
Expand Down
6 changes: 5 additions & 1 deletion script/jvm_test
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env bash

clojure -A:test
set -eo pipefail

clojure -M:test

clojure -M -m borkdude.deps -M:test
53 changes: 31 additions & 22 deletions src/borkdude/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(set! *warn-on-reflection* true)
(def path-separator (System/getProperty "path.separator"))

(def version "1.10.1.763")
(def version "1.10.3.814")
(def deps-clj-version
(-> (io/resource "DEPS_CLJ_VERSION")
(slurp)
Expand Down Expand Up @@ -104,6 +104,8 @@ clj-opts:
-Sthreads Set specific number of download threads
-Strace Write a trace.edn file that traces deps expansion
-- Stop parsing dep options and pass remaining arguments to clojure.main
--version Print the version to stdout and exit
-version Print the version to stdout and exit
The following non-standard options are available only in deps.clj:
Expand Down Expand Up @@ -301,6 +303,8 @@ For more info, see:
string-opt-keyword (get string-opts->keyword arg)]
(cond
(= "--" arg) (assoc acc :args (next command-line-args))
(or (= "-version" arg)
(= "--version" arg)) (assoc acc :version true)
(str/starts-with? arg "-M")
(assoc acc
:mode :main
Expand Down Expand Up @@ -347,17 +351,18 @@ For more info, see:
:else (assoc acc :args command-line-args)))
acc))
java-cmd
(let [java-cmd (which (if windows? "java.exe" "java"))]
(if (str/blank? java-cmd)
(let [java-home (System/getenv "JAVA_HOME")]
(if-not (str/blank? java-home)
(let [f (io/file java-home "bin" "java")]
(if (and (.exists f)
(.canExecute f))
(.getCanonicalPath f)
(or (System/getenv "JAVA_CMD")
(let [java-cmd (which (if windows? "java.exe" "java"))]
(if (str/blank? java-cmd)
(let [java-home (System/getenv "JAVA_HOME")]
(if-not (str/blank? java-home)
(let [f (io/file java-home "bin" "java")]
(if (and (.exists f)
(.canExecute f))
(.getCanonicalPath f)
(throw (Exception. "Couldn't find 'java'. Please set JAVA_HOME."))))
(throw (Exception. "Couldn't find 'java'. Please set JAVA_HOME."))))
(throw (Exception. "Couldn't find 'java'. Please set JAVA_HOME."))))
java-cmd))
java-cmd)))
clojure-file (-> (which "clojure") (io/file))
install-dir (when clojure-file
(with-open [reader (io/reader clojure-file)]
Expand Down Expand Up @@ -499,7 +504,8 @@ For more info, see:
(conj "--tree")))]
;; If stale, run make-classpath to refresh cached classpath
(when (and stale (not (or (:describe args)
(:help args))))
(:help args)
(:version args))))
(when (:verbose args)
(warn "Refreshing classpath"))
(let [res (shell-command (into clj-main-cmd
Expand All @@ -523,6 +529,8 @@ For more info, see:
:else (slurp (io/file cp-file)))]
(cond (:help args) (do (println help-text)
(*exit-fn* 0))
(:version args) (do (println "Clojure CLI version (deps.clj)" version)
(*exit-fn* 0))
(:prep args) (*exit-fn* 0)
(:pom args)
(shell-command (into clj-main-cmd
Expand Down Expand Up @@ -550,7 +558,8 @@ For more info, see:
(:command args)
(let [command (str/replace (:command args) "{{classpath}}" (str cp))
main-cache-opts (when (.exists (io/file main-file))
(slurp main-file))
(-> main-file slurp str/split-lines))
main-cache-opts (str/join " " main-cache-opts)
command (str/replace command "{{main-opts}}" (str main-cache-opts))
command (str/split command #"\s+")
command (into command (:args args))]
Expand All @@ -559,25 +568,25 @@ For more info, see:
(let [exec-args (when-let [aliases (:exec-aliases args)]
["--aliases" aliases])
jvm-cache-opts (when (.exists (io/file jvm-file))
(slurp jvm-file))
main-args (if exec?
(-> jvm-file slurp str/split-lines))
main-cache-opts (when (.exists (io/file main-file))
(-> main-file slurp str/split-lines))
main-opts (if exec?
(into ["-m" "clojure.run.exec"]
exec-args)
(some-> (when (.exists (io/file main-file))
(slurp main-file))
(str/split #"\s")))
main-cache-opts)
cp (if exec?
(str cp path-separator exec-cp)
cp)
main-args (concat [java-cmd]
proxy-settings
[jvm-cache-opts
(:jvm-opts args)
(str "-Dclojure.basis=" basis-file)
jvm-cache-opts
(:jvm-opts args)
[(str "-Dclojure.basis=" basis-file)
(str "-Dclojure.libfile=" libs-file)
"-classpath" cp
"clojure.main"]
main-args)
main-opts)
main-args (filterv some? main-args)
main-args (into main-args (:args args))]
(*process-fn* main-args)))))))
24 changes: 23 additions & 1 deletion test/borkdude/deps_test.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(ns borkdude.deps-test
(:require
[babashka.fs :as fs]
[borkdude.deps :as deps]
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.string :as str]
[clojure.test :as t :refer [deftest is]]))
[clojure.test :as t :refer [deftest is testing]]))

(deftest path-test
(is (str/includes? (with-out-str
Expand All @@ -30,6 +31,27 @@
(is (do (deps/-main "-X" "clojure.core/prn" ":foo" "1")
::success)))

(deftest whitespace-test
(testing "jvm opts"
(let [temp-dir (fs/create-temp-dir)
temp-file (fs/create-file (fs/path temp-dir "temp.txt"))
temp-file-path (str temp-file)
_ (deps/-main "-Sdeps" "{:aliases {:space {:jvm-opts [\"-Dfoo=\\\"foo bar\\\"\"]}}}" "-M:space" "-e"
(format "(spit \"%s\" (System/getProperty \"foo\"))"
temp-file-path))
out (slurp temp-file-path)]
(is (= "\"foo bar\"" out))))
(testing "main opts"
(let [temp-dir (fs/create-temp-dir)
temp-file (fs/create-file (fs/path temp-dir "temp.txt"))
temp-file-path (str temp-file)
_ (deps/-main "-Sdeps"
(format "{:aliases {:space {:main-opts [\"-e\" \"(spit \\\"%s\\\" (+ 1 2 3))\"]}}}"
temp-file-path)
"-M:space")
out (slurp temp-file-path)]
(is (= "6" out)))))

(deftest jvm-proxy-settings-test
(is (= {:host "aHost" :port "1234"} (deps/parse-proxy-info "http://aHost:1234")))
(is (= {:host "aHost" :port "1234"} (deps/parse-proxy-info "http://user:pw@aHost:1234")))
Expand Down

0 comments on commit a301f47

Please sign in to comment.