Skip to content

Commit 979edf6

Browse files
committed
Support Clojure version >= 1.8.0
Was previously requiring a minimum Clojure version of 1.9.0. In order to be able to parse modern Clojure constructs, rewrite-clj will continue to depend on the current version of org.clojure/tools.reader. Notes - Kaocha requires Clojure >= v1.9.0 We still use kaocha (because we like it) for Clojure >= 1.9.0 but use cognitect test-runner to run unit tests under Clojure 1.8.0. - We were using qualified-symbol? which was added in Clojure v1.9.0. Easy enough to effectively inline its source. - Namespaced maps were added in v1.9.0. Had a test to verify namespaced map forms were being coerced to rewrite-clj map nodes. This test can't work in v1.8. That's ok, it was non-sensical, namespaced map forms are converted to maps by the reader, so test wasn't testing what it thought it might be testing. Test deleted. - ##Inf and ##-Inf were added in v1.9.0. Had a test which relied on this reader syntax. This does not work in v1.8. Converted test to instead use resulting ##Inf and ##-Inf values for clj and cljs. - Canary lib testing had been patching some libs to bump Clojure version. Reverted Clojure version bumps for kibit and mutant. - Adjusted Clojure version to current for tooling that needed > v1.8.0 - antq - cli-matic (used in Clojure-run scripts) - clj-kondo - figwheel main (for cljs watch task) - kaocha (for clj watch task) Closes #164
1 parent 539eb89 commit 979edf6

File tree

14 files changed

+56
-65
lines changed

14 files changed

+56
-65
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ For a list of breaking changes see link:#v1-breaking[breaking changes].
1616

1717
=== Unreleased
1818

19+
* rewrite-clj v1 minimimum Clojure version is now v1.8.0 (was formerly v1.9.0) https://github.com/clj-commons/rewrite-clj/issues/164[#164]
1920
* internal rewrite-clj developer facing:
2021
** Migrate from `depstar` to `tools.build`
2122

@@ -575,4 +576,3 @@ _Development has branched off, using the `0.4.x` branch_
575576
=== 0.1.0
576577

577578
* Initial Release
578-

deps.edn

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{:paths ["src" "resources"]
22

3-
:deps {org.clojure/clojure {:mvn/version "1.9.0"}
3+
:deps {org.clojure/clojure {:mvn/version "1.8.0"}
44
org.clojure/tools.reader {:mvn/version "1.3.6"}}
55

66
:aliases {;;
77
;; Clojure versions we support
88
;;
9+
:1.8 {:override-deps {org.clojure/clojure {:mvn/version "1.8.0"}}}
910
:1.9 {:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}}
1011
:1.10 {:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}}
1112

@@ -22,6 +23,7 @@
2223
:lint-cache {:replace-paths ["src"]} ;; when building classpath we want to exclude resources
2324
;; so we do not pick up our own clj-kondo config exports
2425
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2021.09.25"}}
26+
:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}
2527
:main-opts ["-m" "clj-kondo.main"]}
2628

2729
:eastwood {:extra-deps {jonase/eastwood {:mvn/version "0.9.9"}}
@@ -34,6 +36,8 @@
3436
:test-common {:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}}
3537
:extra-paths ["test"]}
3638

39+
:test-isolated {:extra-paths ["test-isolated"]}
40+
3741
;; document block testing
3842
:test-doc-blocks {:replace-deps {org.clojure/clojure {:mvn/version "1.10.3"}
3943
com.github.lread/test-doc-blocks {:mvn/version "1.0.146-alpha"}}
@@ -47,14 +51,21 @@
4751
:test-docs {:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}
4852
:extra-paths ["target/test-doc-blocks/test"]}
4953

50-
;; kaocha for clojure testing
54+
;; kaocha for testing clojure versions>= v1.9
5155
:kaocha {:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.902"}
5256
lambdaisland/kaocha-junit-xml {:mvn/version "0.0.76"}
5357
lambdaisland/kaocha-cloverage {:mvn/version "1.0.75"}}
5458
:main-opts ["-m" "kaocha.runner"]}
5559

60+
;; cognitect test-runner for testing clojure < v1.9
61+
;; (we prefer kaocha but it requires a min Clojure version of 1.9)
62+
:clj-test-runner {:extra-deps {io.github.cognitect-labs/test-runner
63+
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
64+
:main-opts ["-m" "cognitect.test-runner"]}
65+
5666
;; figwheel for clojurescript testing during dev
5767
:fig-test {:extra-deps {com.bhauman/figwheel-main {:mvn/version "0.2.14"}}
68+
:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}
5869
:extra-paths ["target" "test"]
5970
:main-opts ["-m" "figwheel.main" "-b" "fig" "-r"]}
6071

@@ -69,6 +80,7 @@
6980
;; General script deps
7081
;;
7182
:script {:extra-paths ["script"]
83+
:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}
7284
:extra-deps {org.clojure/tools.namespace {:mvn/version "1.1.0"}
7385
cli-matic/cli-matic {:mvn/version "0.4.3"}}}
7486

@@ -116,6 +128,7 @@
116128
:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "1.1.0"}
117129
org.slf4j/slf4j-simple {:mvn/version "1.7.32"} ;; to rid ourselves of logger warnings
118130
}
131+
:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}
119132
:main-opts ["-m" "antq.core"
120133
"--exclude=lambdaisland/[email protected]" ;; https://github.com/lambdaisland/kaocha/issues/208
121134
]}}}

doc/01-user-guide.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ Thanks to @xsc's transfer of rewrite-clj to clj-commons we'll continue on with t
6161
To upgrade to rewrite-clj v1, update your project dependencies.
6262
If you were using both rewrite-cljs and rewrite-clj v0 in your project you can now drop the rewrite-cljs dependency.
6363

64+
Rewrite-clj unit tests are run against the current version of ClojureScript and Clojure versions >= v1.8.0.
65+
We recommend that while bumping your rewrite-clj dependency to v1, that you also bump your Clojure and ClojureScript dependencies to current official releases.
66+
6467
The most notable breaking changes from rewrite-clj v0 relate to handling of namespaced elements:
6568

6669
* Namespaced map handling was incomplete in rewrite-clj, has been reworked a bit and now supports namespaced symbols

doc/02-developer-guide.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Automated testing is setup using GraalVM v21 JDK11.
1919
* Java JDK 1.8 or above
2020
* NodeJs v12 or above
2121
* Clojure v1.10.1.697 or above for `clojure` command
22-
** Note that rewrite-clj v1 itself supports Clojure v1.9 and above
22+
** Note that rewrite-clj v1 itself supports Clojure v1.8 and above
2323
* Babashka v0.3.7 or above
2424
* GraalVM v21.2.0 JDK 11 (if you want to run GraalVM native image tests)
2525

doc/design/01-merging-rewrite-clj-and-rewrite-cljs.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ After some experimentation, my general strategy is to:
191191
.. Grab the a specified release of a project from GitHub via zip download
192192
.. Patch deps to
193193
... Point to rewrite-clj canary release
194-
... Adjust Clojure version if necessary (we are 1.9 and above)
194+
... Adjust Clojure version if necessary (we are 1.8 and above)
195195
.. Adjust sources as necessary
196196
... Ex. rewrite-cljc -> rewrite-clj namespace
197197
... At the time of the writing only zprint v1.1.1. needed a src code hack to get its tests passing.

script/ci_unit_tests.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
(shell/command "bb test-doc"))
2222

2323
(defn clojure-tests []
24-
(doseq [version ["1.9" "1.10"]]
24+
(doseq [version ["1.8" "1.9" "1.10"]]
2525
(shell/command "bb test-clj --clojure-version" version)) )
2626

2727
(defn cljs-tests []

script/test_clj.clj

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
2-
31
#!/usr/bin/env bb
42

53
(ns test-clj
64
(:require [helper.main :as main]
75
[helper.shell :as shell]
86
[lread.status-line :as status]))
97

10-
(def allowed-clojure-versions '("1.9" "1.10"))
8+
(def allowed-clojure-versions '("1.8" "1.9" "1.10"))
119

1210
(defn run-unit-tests [clojure-version]
1311
(status/line :head (str "testing clojure source against clojure v" clojure-version))
14-
(shell/command "clojure"
15-
(str "-M:test-common:kaocha:" clojure-version)
16-
"--reporter" "documentation"))
12+
(if (= "1.8" clojure-version)
13+
(shell/command "clojure"
14+
(str "-M:test-common:clj-test-runner:" clojure-version))
15+
(shell/command "clojure"
16+
(str "-M:test-common:kaocha:" clojure-version)
17+
"--reporter" "documentation")))
1718

1819
(defn run-isolated-tests[clojure-version]
1920
(status/line :head (str "running isolated tests against clojure v" clojure-version))
20-
(shell/command "clojure" (str "-M:kaocha:" clojure-version)
21-
"--profile" "test-isolated"
22-
"--reporter" "documentation"))
21+
(if (= "1.8" clojure-version)
22+
(shell/command "clojure" (str "-M:clj-test-runner:test-isolated:" clojure-version)
23+
"--dir" "test-isolated")
24+
(shell/command "clojure" (str "-M:kaocha:" clojure-version)
25+
"--profile" "test-isolated"
26+
"--reporter" "documentation")))
2327

2428
(def args-usage "Valid args: [options]
2529
2630
Options:
27-
-v, --clojure-version VERSION Test with Clojure [1.9, 1.10] [default: 1.10]
31+
-v, --clojure-version VERSION Test with Clojure [1.8, 1.9, 1.10] [default: 1.10]
2832
--help Show this help")
2933

3034
(defn -main [& args]

script/test_clj_watch.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
;; we simply pass along any args to kaocha, it will validate them
1111
(env/assert-min-versions)
1212
(status/line :head "launching kaocha watch on clojure sources")
13-
(apply shell/command "clojure -M:test-common:kaocha --watch" args))
13+
(apply shell/command "clojure -M:test-common:kaocha:1.9 --watch" args))
1414

1515
(main/when-invoked-as-script
1616
(apply -main *command-line-args*))

script/test_libs.clj

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,6 @@
200200
"[rewrite-clj.zip :as rzip]"
201201
"[rewrite-clj.zip :as rzip] [rewrite-clj.node]"))
202202

203-
;;
204-
;; kibit patch
205-
;;
206-
(defn- kibit-patch [{:keys [home-dir rewrite-clj-version]}]
207-
(patch-deps {:filename (str (fs/file home-dir "project.clj"))
208-
:removals #{'rewrite-clj 'org.clojure/clojure}
209-
:additions [['rewrite-clj rewrite-clj-version]
210-
['org.clojure/clojure "1.9.0"]]}))
211-
212203
;;
213204
;; lein ancient
214205
;;
@@ -239,15 +230,6 @@
239230
"[$1 :exclusions [org.clojure/tools.reader]]")
240231
(->> (spit p)))))
241232

242-
;;
243-
;; mutant
244-
;;
245-
(defn- mutant-patch [{:keys [home-dir rewrite-clj-version]}]
246-
(patch-deps {:filename (str (fs/file home-dir "project.clj"))
247-
:removals #{'rewrite-clj 'org.clojure/clojure}
248-
:additions [['rewrite-clj rewrite-clj-version]
249-
['org.clojure/clojure "1.9.0"]]}))
250-
251233
;;
252234
;; refactor-nrepl
253235
;;
@@ -377,7 +359,7 @@
377359
:root "kibit"
378360
:version "0.1.8"
379361
:github-release {:repo "jonase/kibit"}
380-
:patch-fn kibit-patch
362+
:patch-fn project-clj-v1-patch
381363
:show-deps-fn lein-deps-tree
382364
:test-cmds ["lein test-all"]}
383365
{:name "lein-ancient"
@@ -404,7 +386,7 @@
404386
:note "Dormant project"
405387
:github-release {:repo "jstepien/mutant"
406388
:via :tag}
407-
:patch-fn mutant-patch
389+
:patch-fn project-clj-v1-patch
408390
:show-deps-fn lein-deps-tree
409391
:test-cmds ["lein test"]}
410392
{:name "rewrite-edn"

src/rewrite_clj/node.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@
758758
;; DO NOT EDIT FILE, automatically imported from: rewrite-clj.node.token
759759
(defn token-node
760760
"Create node for an unspecified token of `value`.
761-
761+
762762
```Clojure
763763
(require '[rewrite-clj.node :as n])
764764

0 commit comments

Comments
 (0)