Skip to content

Commit

Permalink
Add nbb test runner (yogthos#174)
Browse files Browse the repository at this point in the history
* Make babashka compatible

* Add nbb test runner

added bb and nbb tests
  • Loading branch information
borkdude authored and yogthos committed Nov 18, 2021
1 parent 9abd043 commit 13f67a9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
jobs:
build:
docker:
- image: clojure:lein-2.8.1
working_directory: /root/markdown-clj
- image: circleci/clojure:openjdk-11-lein-2.9.3-buster-node
working_directory: /home/circleci/markdown-clj
steps:
- checkout
- restore_cache:
Expand All @@ -14,12 +14,12 @@ jobs:
command: |
curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
chmod +x install
sudo install
sudo ./install
- run: lein test
- save_cache:
key: v1-dependency-jars-{{ checksum "project.clj" }}
paths:
- /root/.m2
- /circleci/.m2

workflows:
version: 2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target
.cache
.cpcache
cljs-test-runner-out
node_modules
14 changes: 9 additions & 5 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{:deps {markdown-clj/markdown-clj {:local/root "."}}
:tasks
{test:bb {:doc "Runs tests with babashka"
{test:clj {:doc "Runs tests with JVM Clojure"
:task (clojure "-X:test")}
test:cljs {:doc "Runs tests with ClojureScript"
:task (clojure "-M:cljs-test")}
test:bb {:doc "Runs tests with babashka"
:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}
Expand All @@ -9,7 +13,7 @@
:git/sha "3625153ee66dfcec2ba600851b5b2cbdab8fae6c"}}
:requires ([cognitect.test-runner :as tr])
:task (apply tr/-main "-d" "test" *command-line-args*)}
test:clj {:doc "Runs tests with JVM Clojure"
:task (clojure "-X:test")}
test:cljs {:doc "Runs tests with ClojureScript"
:task (clojure "-M:cljs-test")}}}
-npm-install {:task (shell "npm install")}
test:nbb {:doc "Runs tests with nbb"
:depends [-npm-install]
:task (shell "npx nbb test/markdown/nbb_runner.cljs")}}}
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"nbb": "0.0.109"
}
}
4 changes: 3 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
:auto-clean false

:aliases {"test-cljs" ["shell" "bb" "test:cljs"]
"test" ["do" "test," "test-cljs"]
"test-bb" ["shell" "bb" "test:bb"]
"test-nbb" ["shell" "bb" "test:nbb"]
"test" ["do" "test," "test-cljs", "test-bb", "test-nbb"]
"cleantest" ["do" "clean," "test"]
"install" ["do" "clean," "install"]
"deploy" ["do" "clean," "deploy" "clojars"]}
Expand Down
13 changes: 6 additions & 7 deletions test/markdown/md_test.cljc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns markdown.md-test
(:require [markdown.core :as markdown]
[markdown.tables :as tables]
#?(:clj [clojure.test :refer :all]
:cljs [cljs.test :refer-macros [deftest is testing]])
#?(:cljs [goog.string])))
(:require #?(:cljs [goog.string])
[clojure.test :refer [deftest is]]
[markdown.core :as markdown]
[markdown.tables :as tables]))

(def entry-function
#?(:clj markdown/md-to-html-string
Expand Down Expand Up @@ -327,14 +326,14 @@
(is (= "<p><a href=\"http://foo\">http://foo</a> <a href=\"https://bar/baz\">https://bar/baz</a> <a href=\"http://foo/bar\">foo bar</a></p>"
(entry-function "<http://foo> <https://bar/baz> <a href=\"http://foo/bar\">foo bar</a>")))

#?(:bb nil
#?(:bb nil :org.babashka/nbb nil
:default
(is (= "<p><a href=\"mailto:abc@google.com\">abc@google.com</a></p>"
(#?(:clj org.apache.commons.lang.StringEscapeUtils/unescapeHtml
:cljs goog.string/unescapeEntities)
(entry-function "<abc@google.com>")))))

#?(:bb nil
#?(:bb nil :org.babashka/nbb nil
:default
(is (= "<p><a href=\"mailto:abc_def_ghi@google.com\">abc_def_ghi@google.com</a></p>"
(#?(:clj org.apache.commons.lang.StringEscapeUtils/unescapeHtml
Expand Down
10 changes: 10 additions & 0 deletions test/markdown/nbb_runner.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns nbb-runner
(:require [clojure.string :as str]
[clojure.test :refer [run-tests]]
[nbb.classpath :as cp]))

(cp/add-classpath (str/join ":" ["src/cljs" "src/cljc" "test"]))

(require '[markdown.md-test])

(run-tests 'markdown.md-test)

0 comments on commit 13f67a9

Please sign in to comment.