Skip to content

Commit

Permalink
ref #19 - CLJS tests run (but don't pass, one thing at a time)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenz committed Nov 17, 2018
1 parent 03a848a commit 8969850
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 20 deletions.
8 changes: 8 additions & 0 deletions Deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ Then check your Clojars credentials and push:
Change the documentation linkin `README.md`. Then click on it.


# ClojureScript

Unit tests:

lein cljsbuild test unit-tests




24 changes: 20 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
:description "Compact [sub]command line parsing library, for Clojure"
:url "https://github.com/l3nz/cli-matic"
:license {:name "Eclipse Public License, v2"
:url "http://www.eclipse.org/legal/epl-v20.html"}
:url "http://www.eclipse.org/legal/epl-v20.html"}
:dependencies [[org.clojure/clojure "1.9.0" :scope "provided"]
[org.clojure/clojurescript "1.10.439" :scope "provided"]
[org.clojure/spec.alpha "0.1.143" :scope "provided"]
[org.clojure/tools.cli "0.4.1"]
[orchestra "2017.11.12-1" :scope "provided"]
Expand All @@ -12,11 +13,26 @@
[expound "0.7.1"]]
:scm {:name "git"
;; :tag "..."
:url "https://github.com/l3nz/cli-matic" }
:url "https://github.com/l3nz/cli-matic"}
:plugins [[lein-eftest "0.5.1"]
[jonase/eastwood "0.2.5"]
[lein-kibit "0.1.6"]
[lein-cljfmt "0.5.7"]]
:deploy-repositories [["clojars" {:sign-releases false :url "https://clojars.org/repo"}]
[lein-cljfmt "0.5.7"]
[lein-cljsbuild "1.1.7"]]
:cljsbuild
{:test-commands {"unit-tests" ["node" "target/unit-tests.js"]}
:builds
{:tests
{:source-paths ["src" "test"]
:notify-command ["node" "target/unit-tests.js"]
:compiler {:output-to "target/unit-tests.js"
:optimizations :none
:target :nodejs
:main cli-matic.cljs-runner}}
:production
{:source-paths ["src"]
:compiler {:output-to "target/production.js"
:optimizations :advanced}}}}
:deploy-repositories [["clojars" {:sign-releases false :url "https://clojars.org/repo"}]
["snapshots" {:sign-releases false :url "https://clojars.org/repo"}]])

2 changes: 1 addition & 1 deletion src/cli_matic/help_gen.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
:args (s/cat :cfg ::S/climatic-cfg :cmd ::S/command)
:ret (s/coll-of string?))

(def MISTYPE-ERR-RATIO 1/3)
(def MISTYPE-ERR-RATIO 0.35)

(defn generate-possible-mistypes
"We go searching if we have any candidates
Expand Down
19 changes: 19 additions & 0 deletions test/cli_matic/cljs_runner.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(ns cli-matic.cljs-runner
(:require [cljs.test :refer [run-tests]]
[cli-matic.core-test]
[cli-matic.help-gen-test]
[cli-matic.presets-test]
[cli-matic.utils-test]))

; Turn on console printing. Node can't print to *out* without.
(enable-console-print!)

; This must be a root level call for Node to pick it up.
(run-tests 'cli-matic.core-test
'cli-matic.help-gen-test
'cli-matic.presets-test
'cli-matic.utils-test)




10 changes: 7 additions & 3 deletions test/cli_matic/core_test.cljc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
(ns cli-matic.core-test
(:require [clojure.test :refer :all]
[cli-matic.core :refer :all]
(:require [clojure.test :refer [is are deftest testing]]
[cli-matic.platform :as P]
[clojure.spec.alpha :as s]
[clojure.string :as str]))
[clojure.string :as str]
[cli-matic.core :refer [parse-cmds
run-cmd* ->RV
assert-unique-values
assert-cfg-sanity
parse-cmds-with-defaults]]))

(defn cmd_foo [& opts])
(defn cmd_bar [& opts])
Expand Down
4 changes: 2 additions & 2 deletions test/cli_matic/help_gen_test.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns cli-matic.help-gen-test
(:require [clojure.test :refer :all])
(:require [cli-matic.help-gen :refer :all]))
(:require [clojure.test :refer [is are deftest testing]]
[cli-matic.help-gen :refer [generate-possible-mistypes]]))

(deftest generate-possible-mistypes-test

Expand Down
5 changes: 3 additions & 2 deletions test/cli_matic/presets_test.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns cli-matic.presets-test
(:require [clojure.test :refer :all]
[cli-matic.core :refer :all]))
(:require [clojure.test :refer [is are deftest testing]]
[cli-matic.core :refer [parse-cmds
]]))

(defn cmd_foo [v]
(prn "Foo:" v)
Expand Down
24 changes: 16 additions & 8 deletions test/cli_matic/utils_test.cljc
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
(ns cli-matic.utils-test
(:require [clojure.test :refer :all])
(:require [cli-matic.utils :refer :all])
(:require [cli-matic.platform :as P])
)
(:require [clojure.test :refer [is are deftest testing] ]
[cli-matic.utils :refer [asString asStrVec
indent-string indent
pad deep-merge
all-subcommands-aliases
all-subcommands
canonicalize-subcommand
mk-cli-option
str-distance
candidate-suggestions]]
[cli-matic.platform :as P]))

(deftest asString-test

Expand All @@ -27,7 +34,8 @@

(deftest asStrVec-test

(are [i o] (= (asStrVec i) o)
(are [i o]
(= (asStrVec i) o)

; a string
"x" ["x"]
Expand Down Expand Up @@ -191,10 +199,10 @@
"pippo" "pippo" 0

; one change
"pippo" "Pippo" 1/5
"pippo" "Pippo" 0.20

; compute as prc of longest
"pippox" "Pippo" 2/6
"pippox" "Pippo" 0.334

; nils?
"xxx" nil 1
Expand All @@ -210,7 +218,7 @@
(deftest candidate-suggestions-test

(are [c t r]
(= r (vec (candidate-suggestions c t 1/2)))
(= r (vec (candidate-suggestions c t 0.5)))

; only one
["foo" "bar" "baz" "buzz"] "baar" ["bar" "baz"]
Expand Down

0 comments on commit 8969850

Please sign in to comment.