Skip to content

Commit 15c7f61

Browse files
[test] Remove enrich-classpath testing dependency
1 parent 456ecf8 commit 15c7f61

File tree

7 files changed

+107
-162
lines changed

7 files changed

+107
-162
lines changed

.clj-kondo/config.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
:type-mismatch {:level :off}
2525
:unresolved-namespace {:exclude [clojure.main nrepl.transport js]}}
2626
:output {:progress true
27-
:exclude-files ["data_readers" "tasks"]}}
27+
:exclude-files ["data_readers" "tasks" "base-src.zip"]}}

Makefile

Lines changed: 29 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: test quick-test fast-test eastwood cljfmt cljfmt-fix install fast-install smoketest deploy clean detect_timeout lein-repl repl lint light-kondo docs test_impl
1+
.PHONY: test quick-test eastwood cljfmt cljfmt-fix install fast-install smoketest deploy clean detect_timeout lein-repl repl lint light-kondo docs test_impl
22
.DEFAULT_GOAL := quick-test
33

44
CLOJURE_VERSION ?= 1.11
@@ -17,63 +17,42 @@ ENRICH_CLASSPATH_VERSION="1.18.2"
1717

1818
# Set bash instead of sh for the @if [[ conditions,
1919
# and use the usual safety flags:
20-
SHELL = /bin/bash -Eeu
21-
22-
ifeq ($(OS),Darwin) # macOS
23-
SED_INPLACE = -i ''
24-
else
25-
SED_INPLACE = -i
26-
endif
27-
28-
TEST_RUNNER_SOURCE_DIR = test-runner
29-
30-
$(TEST_RUNNER_SOURCE_DIR):
31-
@if [ ! -d "$(TEST_RUNNER_SOURCE_DIR)" ]; then git clone https://github.com/cognitect-labs/test-runner.git $(TEST_RUNNER_SOURCE_DIR) --depth=1; fi
20+
SHELL = /bin/bash -Ee
21+
22+
# We need Java sources to test Java parsing functionality, but the Docker images
23+
# we use on CircleCI doesn't include src.zip. So we have to download them from
24+
# Github and repackage in a form that is resemblant to src.zip from normal
25+
# distributions.
26+
base-src.zip:
27+
wget https://github.com/adoptium/jdk21u/archive/refs/tags/jdk-21.0.5+3.zip -O full-src.zip
28+
unzip -q full-src.zip
29+
cp -r jdk21u-*/src/java.base/share/classes java.base
30+
cp -r jdk21u-*/src/java.desktop/share/classes java.desktop
31+
zip -qr base-src.zip java.base java.desktop
32+
rm -rf java.base java.desktop jdk21u-* full-src.zip
3233

3334
test/resources/cider/nrepl/clojuredocs/export.edn:
3435
curl -o $@ https://github.com/clojure-emacs/clojuredocs-export-edn/raw/master/exports/export.compact.edn
3536

3637
dump-version:
3738
echo '"$(PROJECT_VERSION)"' > resources/cider/nrepl/version.edn
3839

39-
.inline-deps: project.clj clean
40-
rm -f .no-mranderson
40+
target/srcdeps: project.clj
4141
lein with-profile -user,-dev inline-deps
4242
# Remove cljfmt.main because it depends on tools.cli which we explicitly removed.
4343
rm -f target/srcdeps/cider/nrepl/inlined/deps/cljfmt/*/cljfmt/main.clj
44-
touch $@
4544

46-
test_impl: $(TEST_RUNNER_SOURCE_DIR) test/resources/cider/nrepl/clojuredocs/export.edn
47-
rm -f .no-mranderson
45+
test_impl: test/resources/cider/nrepl/clojuredocs/export.edn base-src.zip
4846
@if [[ "$$PARSER_TARGET" == "parser-next" ]] ; then \
49-
export SKIP_INLINING_TEST_DEPS=true; \
50-
bash 'lein' 'update-in' ':plugins' 'conj' "[mx.cider/lein-enrich-classpath \"$(ENRICH_CLASSPATH_VERSION)\"]" '--' 'with-profile' $(TEST_PROFILES),+cognitest,+$(CLOJURE_VERSION) 'update-in' ':middleware' 'conj' 'cider.enrich-classpath.plugin-v2/middleware' '--' 'repl' | grep " -cp " > .test-classpath; \
51-
cat .test-classpath; \
52-
eval "$$(cat .test-classpath)"; \
53-
rm .test-classpath; \
54-
elif [[ "$$PARSER_TARGET" == "parser" ]] ; then \
55-
export SKIP_INLINING_TEST_DEPS=true; \
56-
bash 'lein' 'update-in' ':plugins' 'conj' "[mx.cider/lein-enrich-classpath \"$(ENRICH_CLASSPATH_VERSION)\"]" '--' 'with-profile' $(TEST_PROFILES),+cognitest,+$(CLOJURE_VERSION) 'update-in' ':middleware' 'conj' 'cider.enrich-classpath.plugin-v2/middleware' '--' 'repl' | grep " -cp " > .test-classpath; \
57-
cat .test-classpath; \
58-
sed $(SED_INPLACE) 's/--add-opens=jdk.compiler\/com.sun.tools.javac.code=ALL-UNNAMED//g' .test-classpath; \
59-
sed $(SED_INPLACE) 's/--add-opens=jdk.compiler\/com.sun.tools.javac.tree=ALL-UNNAMED//g' .test-classpath; \
60-
cat .test-classpath; \
61-
eval "$$(cat .test-classpath)"; \
62-
rm .test-classpath; \
63-
elif [[ "$$PARSER_TARGET" == "legacy-parser" ]] ; then \
64-
export SKIP_INLINING_TEST_DEPS=true; \
65-
lein with-profile +$(CLOJURE_VERSION),$(TEST_PROFILES) test; \
47+
lein with-profile $(TEST_PROFILES),+$(CLOJURE_VERSION),+parser-next test; \
6648
else \
67-
echo "PARSER_TARGET unset!"; \
68-
exit 1; \
49+
lein with-profile $(TEST_PROFILES),+$(CLOJURE_VERSION) test; \
6950
fi
7051

71-
test: clean .inline-deps
52+
test: target/srcdeps
7253
@make test_impl TEST_PROFILES="$(TEST_PROFILES),+plugin.mranderson/config"
7354

74-
quick-test: clean test_impl
75-
76-
fast-test: quick-test
55+
quick-test: test_impl
7756

7857
eastwood:
7958
lein with-profile -user,-dev,+$(CLOJURE_VERSION),+deploy,+eastwood eastwood
@@ -85,47 +64,28 @@ cljfmt-fix:
8564
lein with-profile -user,-dev,+$(CLOJURE_VERSION),+cljfmt cljfmt fix
8665

8766
.make_kondo_prep: project.clj .clj-kondo/config.edn
88-
touch .no-pedantic
89-
touch .no-mranderson
90-
lein with-profile -user,-dev,+test,+clj-kondo,+deploy,+$(CLOJURE_VERSION) clj-kondo --copy-configs --dependencies --lint '$$classpath' > $@
91-
rm -f .no-pedantic
92-
rm -f .no-mranderson
67+
CIDER_NO_MRANDERSON="true" CIDER_NO_PEDANTIC="true" lein with-profile -user,-dev,+test,+clj-kondo,+deploy,+$(CLOJURE_VERSION) clj-kondo --copy-configs --dependencies --lint '$$classpath' > $@
9368

9469
kondo: .make_kondo_prep clean
95-
touch .no-pedantic
96-
touch .no-mranderson
97-
lein with-profile -user,-dev,+test,+clj-kondo,+deploy,+$(CLOJURE_VERSION) clj-kondo
98-
rm -f .no-pedantic
99-
rm -f .no-mranderson
70+
CIDER_NO_MRANDERSON="true" CIDER_NO_PEDANTIC="true" lein with-profile -user,-dev,+test,+clj-kondo,+deploy,+$(CLOJURE_VERSION) clj-kondo
10071

10172
# A variation that does not analyze the classpath, as it OOMs otherwise on CircleCI.
10273
light-kondo: clean
103-
touch .no-pedantic
104-
touch .no-mranderson
105-
lein with-profile -user,-dev,+test,+clj-kondo,+deploy,+$(CLOJURE_VERSION) clj-kondo
106-
rm -f .no-pedantic
107-
rm -f .no-mranderson
74+
CIDER_NO_MRANDERSON="true" CIDER_NO_PEDANTIC="true" lein with-profile -user,-dev,+test,+clj-kondo,+deploy,+$(CLOJURE_VERSION) clj-kondo
10875

10976
lint: kondo cljfmt eastwood
11077

111-
# PROJECT_VERSION=0.49.3 make install
112-
install: dump-version check-install-env .inline-deps
113-
rm -f .no-mranderson
114-
touch .no-pedantic
115-
lein with-profile -user,-dev,+$(CLOJURE_VERSION),+plugin.mranderson/config install
116-
touch .no-pedantic
117-
make clean
78+
# PROJECT_VERSION=x.y.z make install
79+
install: dump-version check-install-env target/srcdeps
80+
CIDER_NO_PEDANTIC="true" lein with-profile -user,-dev,+$(CLOJURE_VERSION),+plugin.mranderson/config install
11881
git checkout resources/cider/nrepl/version.edn
11982

120-
# PROJECT_VERSION=0.49.3 make fast-install
83+
# PROJECT_VERSION=x.y.z make fast-install
12184
fast-install: dump-version check-install-env
12285
lein with-profile -user,-dev,+$(CLOJURE_VERSION) install
123-
make clean
12486
git checkout resources/cider/nrepl/version.edn
12587

126-
smoketest:
127-
export SKIP_INLINING_TEST_DEPS=true
128-
make install
88+
smoketest: install
12989
cd test/smoketest && \
13090
lein with-profile -user,-dev,+$(CLOJURE_VERSION) uberjar && \
13191
java -jar target/smoketest-0.1.0-SNAPSHOT-standalone.jar
@@ -138,7 +98,7 @@ detect_timeout:
13898

13999
# Deployment is performed via CI by creating a git tag prefixed with "v".
140100
# Please do not deploy locally as it skips various measures (particularly around mranderson).
141-
deploy: check-env .inline-deps
101+
deploy: check-env target/srcdeps
142102
rm -f .no-mranderson
143103
lein with-profile -user,+$(CLOJURE_VERSION),+plugin.mranderson/config deploy clojars
144104

@@ -161,7 +121,6 @@ endif
161121
clean:
162122
lein with-profile -user clean
163123
cd test/smoketest && lein with-profile -user clean
164-
rm -f .inline-deps
165124

166125
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
167126
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ make repl
7676
PARSER_TARGET=parser-next make test
7777
7878
# Run tests, without using mranderson (considerably faster)
79-
PARSER_TARGET=parser-next make fast-test
79+
PARSER_TARGET=parser-next make quick-test
8080
8181
# Install the project in your local ~/.m2 directory, using mranderson (recommended)
8282
# The JVM flag is a temporary workaround.

project.clj

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,47 @@
11
(def fipp-version "0.6.26")
2+
(def jdk8? (= (System/getProperty "java.specification.version") "1.8"))
3+
(def jdk21? (= (System/getProperty "java.specification.version") "21"))
4+
5+
;; Needed to be added onto classpath to test Java parser functionality.
6+
(def jdk-21-sources-archive
7+
(delay
8+
(let [src-zip (clojure.java.io/file "base-src.zip")]
9+
(if (.exists src-zip)
10+
(do (println "Found JDK sources:" src-zip)
11+
[src-zip])
12+
(do (println "base-src.zip not found. Run `make base-src.zip` to properly run all the tests.")
13+
nil)))))
14+
15+
;; Needed to run tests on JDK8.
16+
(def tools-jar
17+
(delay
18+
(let [java-home (System/getProperty "java.home")
19+
tools-jar-paths [(clojure.java.io/file java-home "tools.jar")
20+
(clojure.java.io/file java-home "lib" "tools.jar")
21+
(clojure.java.io/file java-home ".." "tools.jar")
22+
(clojure.java.io/file java-home ".." "lib" "tools.jar")]
23+
tools-jar (some #(when (.exists %) %) tools-jar-paths)]
24+
(assert tools-jar (str "tools.jar was not found in " java-home))
25+
(println "Found tools.jar:" tools-jar)
26+
(str tools-jar))))
27+
28+
(def dev-test-common-profile
29+
{:dependencies '[[org.clojure/clojurescript "1.11.60" :scope "provided"]
30+
;; 1.3.7 and 1.4.7 are working, but we need 1.3.7 for JDK8
31+
[ch.qos.logback/logback-classic "1.3.7"]
32+
[org.clojure/test.check "1.1.1"]
33+
[cider/piggieback "0.5.3"]
34+
[nubank/matcher-combinators "3.9.1"]]
35+
:source-paths (cond-> ["test/src"]
36+
;; We only include sources with JDK21 because we only
37+
;; repackage sources for that JDK. Sources from one JDK are
38+
;; not compatible with other JDK for our test purposes.
39+
jdk21? (into @jdk-21-sources-archive)
40+
jdk8? (conj @tools-jar))
41+
:global-vars {'*assert* true}
42+
:java-source-paths ["test/java"]
43+
:jvm-opts ["-Djava.util.logging.config.file=test/resources/logging.properties"]
44+
:resource-paths ["test/java" "test/resources"]})
245

346
(defproject cider/cider-nrepl (or (not-empty (System/getenv "PROJECT_VERSION"))
447
"0.0.0")
@@ -18,23 +61,22 @@
1861
org.clojure/clojurescript]]
1962
^:inline-dep [cljfmt "0.9.2" :exclusions [org.clojure/clojurescript
2063
org.clojure/tools.cli]]
21-
~(with-meta '[org.clojure/tools.namespace "1.3.0"]
22-
;; :cognitest uses tools.namespace, so we cannot inline it while running tests.
23-
{:inline-dep (not= "true" (System/getenv "SKIP_INLINING_TEST_DEPS"))})
64+
^:inline-dep [org.clojure/tools.namespace "1.3.0" :exclusions [org.clojure/clojurescript
65+
org.clojure/tools.cli]]
2466
^:inline-dep [io.github.tonsky/clj-reload "0.6.0" :exclusions [org.clojure/clojure]]
2567
^:inline-dep [org.clojure/tools.reader "1.4.1"]
2668
[mx.cider/logjam "0.3.0" :exclusions [org.clojure/clojure]]]
27-
; see Clojure version matrix in profiles below
69+
; see Clojure version matrix in profiles below
2870

2971
:pedantic? ~(if (and (System/getenv "CI")
30-
(not (-> ".no-pedantic" java.io.File. .exists)))
72+
(not (System/getenv "CIDER_NO_PEDANTIC")))
3173
:abort
3274
;; :pedantic? can be problematic for certain local dev workflows:
3375
false)
3476

3577
;; mranderson cannot be put in a profile (as the other plugins),
3678
;; so we conditionally disable it, because otherwise clj-kondo cannot run.
37-
:plugins ~(if (-> ".no-mranderson" java.io.File. .exists)
79+
:plugins ~(if (System/getenv "CIDER_NO_MRANDERSON")
3880
[]
3981
'[[thomasa/mranderson "0.5.4-SNAPSHOT"]])
4082

@@ -78,62 +120,28 @@
78120
:password :env/clojars_password
79121
:sign-releases false}]]
80122

81-
:profiles {:provided {:dependencies [[org.clojure/clojure "1.10.3"]
82-
[org.clojure/clojurescript "1.11.60" :scope "provided"]
83-
[com.cognitect/transit-clj "1.0.333"]
84-
[com.fasterxml.jackson.core/jackson-core "2.17.0"]
85-
[commons-codec "1.16.1"]
86-
[com.cognitect/transit-java "1.0.371"]
87-
[com.google.errorprone/error_prone_annotations "2.26.1"]
88-
[com.google.code.findbugs/jsr305 "3.0.2"]]
89-
:test-paths ["test/spec"]}
123+
:profiles {:provided {:dependencies [[org.clojure/clojure "1.11.4"]]}
124+
90125
:1.10 {:dependencies [[org.clojure/clojure "1.10.3"]
91-
[org.clojure/clojurescript "1.10.520" :scope "provided"]]
92-
:test-paths ["test/spec"]}
126+
[org.clojure/clojurescript "1.10.520" :scope "provided"]]}
93127
:1.11 {:dependencies [[org.clojure/clojure "1.11.4"]
94-
[org.clojure/clojurescript "1.11.60" :scope "provided"]]
95-
:test-paths ["test/spec"]}
128+
[org.clojure/clojurescript "1.11.60" :scope "provided"]]}
96129
:1.12 {:dependencies [[org.clojure/clojure "1.12.0-rc1"]
97130
[org.clojure/clojurescript "1.11.60" :scope "provided"]]}
98131

99132
:maint {:source-paths ["src" "maint"]
100133
:dependencies [[org.clojure/tools.cli "1.1.230"]]}
101134

102-
:test {:global-vars {*assert* true}
103-
:source-paths ["test/src"]
104-
:java-source-paths ["test/java"]
105-
:jvm-opts ["-Djava.util.logging.config.file=test/resources/logging.properties"
106-
"-Dcider.internal.testing=true"]
107-
:resource-paths ["test/resources"]
108-
:dependencies [;; 1.3.7 and 1.4.7 are working, but we need 1.3.7 for JDK8
109-
[ch.qos.logback/logback-classic "1.3.7"]
110-
[org.clojure/test.check "1.1.1"]
111-
[org.apache.httpcomponents/httpclient "4.5.14" :exclusions [commons-logging]]
112-
[leiningen-core "2.11.2" :exclusions [org.clojure/clojure
113-
commons-codec
114-
com.google.code.findbugs/jsr305]]
115-
[cider/piggieback "0.5.3"]
116-
[nubank/matcher-combinators "3.9.1"]]}
117-
118-
;; Running the tests with enrich-classpath doing its thing isn't compatible with `lein test`
119-
;; (because there's no such thing as "run `lein test` using this specific classpath"),
120-
;; So we use cognitect.test-runner instead.
121-
:cognitest {:dependencies [[org.clojure/tools.namespace "1.5.0"]
122-
[org.clojure/tools.cli "1.1.230"]]
123-
:source-paths ["test-runner/src"]
124-
;; This piece of middleware dynamically adds the test paths to a cognitect.test-runner main invocation.
125-
:middleware [~(do
126-
(defn add-cognitest [{:keys [test-paths] :as project}]
127-
(assert (seq test-paths))
128-
(let [cmd (reduce into [["cognitect.test-runner"]
129-
(vec
130-
(interleave (take (count test-paths)
131-
(repeat "--dir"))
132-
test-paths))
133-
["--namespace-regex" (pr-str ".*")]
134-
["--exclude" "cognitest-exclude"]])]
135-
(assoc-in project [:enrich-classpath :main] (clojure.string/join " " cmd))))
136-
`add-cognitest)]}
135+
:dev ~dev-test-common-profile
136+
137+
:test ~(-> dev-test-common-profile
138+
(update :dependencies conj '[leiningen-core "2.11.2"
139+
:exclusions [org.clojure/clojure
140+
commons-codec
141+
com.google.code.findbugs/jsr305]]))
142+
143+
:parser-next {:jvm-opts ["--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"
144+
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"]}
137145

138146
;; Need ^:repl because of: https://github.com/technomancy/leiningen/issues/2132
139147
:repl ^:repl [:test

0 commit comments

Comments
 (0)