Fix remaining args when invoking -m

This commit is contained in:
Michiel Borkent 2021-11-02 13:46:51 +01:00
parent 73426de206
commit 19415f6363
3 changed files with 6 additions and 7 deletions

View file

@ -585,8 +585,8 @@ Use bb run --help to show this help output.
(update opts-map :expressions (fnil conj []) (first options))))
("--main", "-m",)
(let [options (next options)]
(recur (next options)
(assoc opts-map :main (first options))))
(assoc opts-map :main (first options)
:command-line-args (rest options)))
("--run")
(parse-run-opts opts-map (next options))
("--tasks")

View file

@ -54,7 +54,8 @@
(let [v (bb nil "--describe")]
(is (:babashka/version v))
(is (:feature/xml v)))
(is (= {:force? true} (main/parse-opts ["--force"]))))
(is (= {:force? true} (main/parse-opts ["--force"])))
(is (= {:main "foo", :command-line-args '("-h")} (main/parse-opts ["-m" "foo" "-h"]))))
(deftest version-test
(is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT")))
@ -217,7 +218,6 @@
(testing "init with a task name after it"
(test-utils/with-config '{:tasks {thing (println (init-test/do-a-thing))}} ; make a task available
(is (= "foo\n" (test-utils/bb nil "--init" "test-resources/babashka/init_test.clj" "thing"))))))
(deftest preloads-test
;; THIS TEST REQUIRES:

View file

@ -1,17 +1,16 @@
(ns babashka.uberscript-test
(:require
[babashka.test-utils :as tu]
[clojure.edn :as edn]
[clojure.test :as t :refer [deftest is testing]]))
(deftest uberscript-test
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
(.deleteOnExit tmp-file)
(is (empty? (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main" "--uberscript" (.getPath tmp-file))))
(is (empty? (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "uberscript" (.getPath tmp-file) "-m" "my.main" )))
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
(tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4")))
(testing "order of namespaces is correct"
(tu/bb nil "--classpath" "test-resources/babashka/uberscript/src" "-m" "my.main" "--uberscript" (.getPath tmp-file))
(tu/bb nil "--classpath" "test-resources/babashka/uberscript/src" "uberscript" (.getPath tmp-file) "-m" "my.main")
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
(tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4"))))))