Skip to content

Commit cc5d723

Browse files
committed
Add :clj-kondo-test alias for local testing
Adds a deps.edn alias to run clj-kondo hook tests locally: clj -M:clj-kondo-test This runs the same hook verification tests as CI but via the Clojure test-runner instead of shell scripts.
1 parent 9580029 commit cc5d723

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

deps.edn

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,12 @@
7171
:exec-args {:installer :local
7272
:artifact "target/libpython-clj.jar"}}
7373

74+
:clj-kondo-test
75+
{:extra-deps {com.cognitect/test-runner
76+
{:git/url "https://github.com/cognitect-labs/test-runner"
77+
:sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}}
78+
:extra-paths ["test"]
79+
:main-opts ["-m" "cognitect.test-runner"
80+
"-n" "clj-kondo.hook-test"]}
81+
7482
}}

test/clj_kondo/hook_test.clj

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(ns clj-kondo.hook-test
2+
(:require [clojure.test :refer [deftest testing is]]
3+
[clojure.java.shell :refer [sh]]
4+
[clojure.string :as str]))
5+
6+
(def ^:private config-dir
7+
"resources/clj-kondo.exports/clj-python/libpython-clj")
8+
9+
(def ^:private fixtures-dir
10+
"test/clj_kondo/fixtures")
11+
12+
(defn- run-clj-kondo [file]
13+
(sh "clj-kondo" "--lint" file "--config-dir" config-dir))
14+
15+
(defn- has-require-python-errors? [output]
16+
(boolean (re-find #"(Unknown require option|:bind-ns|:reload|:no-arglists)" output)))
17+
18+
(defn- has-unresolved-refer-errors? [output]
19+
(boolean (re-find #"Unresolved symbol: (webpush|secure_filename|urlencode|urlparse)" output)))
20+
21+
(deftest require-python-hook-test
22+
(testing "require_python_test.clj - basic require-python usage"
23+
(let [{:keys [out err]} (run-clj-kondo (str fixtures-dir "/require_python_test.clj"))
24+
output (str out err)]
25+
(is (not (has-require-python-errors? output))
26+
(str "Found require-python errors in output:\n" output))
27+
(is (not (has-unresolved-refer-errors? output))
28+
(str "Found unresolved symbol errors for referred symbols:\n" output)))))
29+
30+
(deftest require-python-edge-cases-test
31+
(testing "require_python_edge_cases.clj - edge cases and variations"
32+
(let [{:keys [out err]} (run-clj-kondo (str fixtures-dir "/require_python_edge_cases.clj"))
33+
output (str out err)]
34+
(is (not (has-require-python-errors? output))
35+
(str "Found require-python errors in output:\n" output))
36+
(is (not (has-unresolved-refer-errors? output))
37+
(str "Found unresolved symbol errors for referred symbols:\n" output)))))

0 commit comments

Comments
 (0)