From fcba19a61203f9a5f3483195a39f0ecac6feadfb Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Tue, 22 Aug 2017 08:59:37 -0700 Subject: [PATCH 1/2] Use cljs.core for cli arguments in cljs.js --- src/js/cljs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/cljs.js b/src/js/cljs.js index f0026a99..0c34d268 100644 --- a/src/js/cljs.js +++ b/src/js/cljs.js @@ -253,7 +253,7 @@ function initClojureScriptEngine(opts: CLIOptsType): void { if (args != null && args.length > 0) { // $FlowIssue: context can have globals - ClojureScriptContext.lumo.core._STAR_command_line_args_STAR_ = + ClojureScriptContext.cljs.core._STAR_command_line_args_STAR_ = // $FlowIssue: context can have globals ClojureScriptContext.cljs.core.seq(args); } From 6b96ff2463a36ca21d23744b3df72e6ea07759c2 Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Tue, 22 Aug 2017 12:10:40 -0700 Subject: [PATCH 2/2] Add simple command line argument tests --- .travis.yml | 2 +- appveyor.yml | 2 +- circle.yml | 2 +- test/lumo/repl_tests.cljs | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e0d210c..6aa6577b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ script: - yarn test - boot test - boot release-ci -- ./build/lumo -c test scripts/lumo_test.cljs +- ./build/lumo -c test scripts/lumo_test.cljs --test-cli-option true after_success: - chmod a+x build/lumo - zip -j build/lumo.zip build/lumo diff --git a/appveyor.yml b/appveyor.yml index a2431f37..1c6fc3ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,7 +32,7 @@ test_script: - yarn test - cmd: boot test - cmd: boot release-ci - - cmd: build\lumo.exe --classpath test scripts\lumo_test.cljs + - cmd: build\lumo.exe --classpath test scripts\lumo_test.cljs --test-cli-option true artifacts: - path: build diff --git a/circle.yml b/circle.yml index 34ba53ed..430c46f7 100644 --- a/circle.yml +++ b/circle.yml @@ -51,7 +51,7 @@ test: - yarn test - boot test - boot release-ci - - ./build/lumo -c test scripts/lumo_test.cljs + - ./build/lumo -c test scripts/lumo_test.cljs --test-cli-option true post: - chmod a+x build/lumo - zip -j build/lumo.zip build/lumo diff --git a/test/lumo/repl_tests.cljs b/test/lumo/repl_tests.cljs index 8804e757..cbb28db3 100644 --- a/test/lumo/repl_tests.cljs +++ b/test/lumo/repl_tests.cljs @@ -136,3 +136,11 @@ Special Form (is (= () (lumo/apropos ffirst))) (is (= '(cljs.core/ffirst cljs.core/nfirst) (lumo/apropos #"[a-z]+first"))) (is (= '(cljs.core/aget) (lumo/apropos "aget")))) + +(when test-util/lumo-env? + (deftest test-cli-args + ;; this requires to run: + ;; ./build/lumo -c test scripts/lumo_test.cljs --test-cli-option true + (is (not-any? #(= (.-execPath js/process) %1) cljs.core/*command-line-args*) "It should not contain process.execPath") + (is (not-any? #(= "nexe.js" %1) cljs.core/*command-line-args*) "It should not contain the path to the JavaScript file being executed") + (is (= ["--test-cli-option" "true"] cljs.core/*command-line-args*) "It should contained the expected options (in order)")))