Fix #1506: :exec-args in task should override :exec-args on fn metadata

This commit is contained in:
Michiel Borkent 2023-02-28 19:45:49 +01:00
parent 3f4ac12cc4
commit 076a2774be
4 changed files with 17 additions and 7 deletions

View file

@ -14,6 +14,7 @@ A preview of the next release can be installed from
- [#1487](https://github.com/babashka/babashka/issues/1487): `babashka.tasks/clojure` should be supported without arguments to start a REPL
- [#1496](https://github.com/babashka/babashka/issues/1496): Add `set-agent-send-executor!` and `set-agent-send-off-executor!`
- [#1489](https://github.com/babashka/babashka/issues/1489): Don't overwrite non-empty, non-jar files when writing uberscript/uberjar ([@bobisageek](https://github.com/bobisageek))
- [#1506](https://github.com/babashka/babashka/issues/1506): `:exec-args` in task should override `:exec-args` on fn metadata
## 1.1.173 (2023-02-04)

View file

@ -21,14 +21,16 @@
ns (:ns (meta the-var))
ns-meta (meta ns)
ct (babashka.tasks/current-task)
exec-args (babashka.cli/merge-opts (:exec-args (:org.babashka/cli ns-meta))
(:exec-args (:org.babashka/cli the-var-meta))
(:exec-args (:org.babashka/cli ct))
(:exec-args ct)
(:exec-args extra-opts))
cli-opts (babashka.cli/merge-opts (:org.babashka/cli ns-meta)
(:org.babashka/cli the-var-meta)
(:org.babashka/cli ct)
extra-opts)
task-exec-args (:exec-args ct)
cli-exec-args (:exec-args cli-opts)
exec-args {:exec-args (babashka.cli/merge-opts cli-exec-args task-exec-args)}
cli-opts (babashka.cli/merge-opts exec-args cli-opts)
cli-opts (assoc cli-opts :exec-args exec-args)
opts (babashka.cli/parse-opts *command-line-args* cli-opts)]
(the-var opts))"
(random-uuid)

View file

@ -2,7 +2,9 @@
{:org.babashka/cli {:coerce {:foo []}}})
(defn exec-test
{:org.babashka/cli {:coerce {:bar :keyword}}}
{:org.babashka/cli
{:exec-args {:foo :foo}
:coerce {:bar :keyword}}}
[m]
(if (:meta m)
(prn (meta m))

View file

@ -37,8 +37,13 @@
(testing "task exec args"
(u/with-config
"{:deps {}
:tasks {foo {:exec-args {:foo :bar}
:task (exec 'babashka.exec-test/exec-test)}}}"
:tasks {foo {:task (exec 'babashka.exec-test/exec-test)}}}"
(is (= {:foo :foo, :bar :yeah}
(edn/read-string (bb "-cp" "test-resources" "run" "foo" "--bar" "yeah")))))
(u/with-config
"{:deps {}
:tasks {foo {:exec-args {:foo :bar}
:task (exec 'babashka.exec-test/exec-test)}}}"
(is (= {:foo :bar, :bar :yeah}
(edn/read-string (bb "-cp" "test-resources" "run" "foo" "--bar" "yeah"))))))
(testing "meta"