Skip to content

Commit

Permalink
Add Babashka tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eerohele committed Nov 24, 2023
1 parent 25b39d2 commit 0759910
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- uses: DeLaGuardo/setup-clojure@12.1
with:
cli: '1.11.1.1208'
bb: '1.3.186'

- uses: actions/cache@v3
with:
Expand All @@ -53,3 +54,5 @@ jobs:
- run: npm install

- run: npx shadow-cljs compile test && node out/test.js

- run: bb test/run.bb
5 changes: 4 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
test-bb:
bb test/run.bb

npm:
npm install

Expand All @@ -8,7 +11,7 @@ test-clj:
clojure -A:dev -X cognitect.test-runner.api/test
clojure -X:dev user/xr! '{:path "check"}'

test: test-cljs test-clj
test: test-bb test-cljs test-clj

bench:
clojure -X:dev user/xr! '{:path "bench"}'
Expand Down
2 changes: 2 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:deps {org.clojure/test.check {:mvn/version "1.1.1"}
com.widdindustries/time-literals {:mvn/version "0.1.10"}}}
4 changes: 4 additions & 0 deletions test/me/flowthing/pp_cpp_test.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(ns me.flowthing.pp-cpp-test)

;; Dummy namespace to prevent Babashka from running tests that compare
;; the output of clojure.pprint/pprint and me.flowthing.pp/pprint.
4 changes: 4 additions & 0 deletions test/me/flowthing/pp_gen_test.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(ns me.flowthing.pp-gen-test)

;; Dummy namespace to prevent Babashka from running Clojure-only
;; generative tests.
12 changes: 12 additions & 0 deletions test/me/flowthing/pp_record_test.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns me.flowthing.pp-record-test
(:require [clojure.test :refer [deftest is]]
[me.flowthing.pp.test :refer [pp]]))

(defrecord R [x])
(defrecord R?*+! [])

(deftest print-record
(is (= "#sci.impl.records.SciRecord{:x\n {:a\n 1,\n :b\n 2,\n :c\n 3,\n :d\n 4}}\n"
(pp (->R {:a 1 :b 2 :c 3 :d 4}) :max-width 31)))
(is (= "#sci.impl.records.SciRecord{}\n"
(pp (->R?*+!)))))
16 changes: 16 additions & 0 deletions test/run.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bb

(require '[clojure.test :as t]
'[babashka.classpath :as cp])

(cp/add-classpath "src:test")

(require 'me.flowthing.pp-test)
(require 'me.flowthing.pp-record-test)

(def test-results
(t/run-tests 'me.flowthing.pp-test 'me.flowthing.pp-record-test))

(let [{:keys [fail error]} test-results]
(when (pos? (+ fail error))
(System/exit 1)))

0 comments on commit 0759910

Please sign in to comment.