Skip to content

Commit 8c3e2d7

Browse files
committed
add intellij integration test structure
1 parent 6a488c1 commit 8c3e2d7

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

.github/workflows/test.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Tests
2+
on:
3+
pull_request:
4+
5+
permissions:
6+
contents: read
7+
checks: write
8+
pull-requests: write
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Java
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: 'temurin'
22+
java-version: 17
23+
cache: 'gradle'
24+
25+
- name: Install Clojure
26+
uses: DeLaGuardo/setup-clojure@master
27+
with:
28+
bb: '1.12.196'
29+
cli: 1.12.0.1530
30+
31+
- name: Run tests
32+
run: ./gradlew test
33+
34+
- name: Publish Test Report
35+
uses: mikepenz/action-junit-report@v5
36+
if: success() || failure() # always run even if the previous step fails
37+
with:
38+
report_paths: '**/build/test-results/test/TEST-*.xml'
39+
simplified_summary: true
40+
comment: true

bb.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{:paths ["src/scripts"]
22
:tasks {tag scripts/tag
33
build-plugin scripts/build-plugin
4+
test scripts/tests
45
install-plugin scripts/install-plugin
56
publish-plugin scripts/publish-plugin}}

build.gradle.kts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,24 @@ repositories {
3535

3636
dependencies {
3737
implementation ("org.clojure:clojure:1.12.0")
38-
implementation ("com.github.ericdallo:clj4intellij:0.7.1")
38+
implementation ("com.github.ericdallo:clj4intellij:0.8.0")
3939
implementation ("seesaw:seesaw:1.5.0")
4040
implementation ("camel-snake-kebab:camel-snake-kebab:0.4.3")
4141
implementation ("com.rpl:proxy-plus:0.0.9")
4242
implementation ("dev.weavejester:cljfmt:0.13.0")
4343
implementation ("com.github.clojure-lsp:clojure-lsp:2025.01.22-23.28.23")
44+
implementation ("nrepl:nrepl:1.3.1")
45+
46+
testImplementation("junit:junit:latest.release")
47+
testImplementation("org.junit.platform:junit-platform-launcher:latest.release")
48+
testRuntimeOnly ("dev.clojurephant:jovial:0.4.2")
4449
}
4550

4651
sourceSets {
4752
main {
4853
java.srcDirs("src/main", "src/gen")
4954
if (project.gradle.startParameter.taskNames.contains("buildPlugin") ||
55+
project.gradle.startParameter.taskNames.contains("clojureRepl") ||
5056
project.gradle.startParameter.taskNames.contains("runIde")) {
5157
resources.srcDirs("src/main/dev-resources")
5258
}
@@ -146,6 +152,10 @@ tasks {
146152
systemProperty("jb.consents.confirmation.enabled", "false")
147153
}
148154

155+
test {
156+
systemProperty("idea.mimic.jar.url.connection", "true")
157+
}
158+
149159
signPlugin {
150160
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
151161
privateKey.set(System.getenv("PRIVATE_KEY"))
@@ -165,6 +175,26 @@ tasks {
165175
enabled = false
166176
}
167177

178+
clojureRepl {
179+
dependsOn("compileClojure")
180+
classpath.from(sourceSets.main.get().runtimeClasspath
181+
+ file("build/classes/kotlin/main")
182+
+ file("build/clojure/main")
183+
)
184+
// doFirst {
185+
// println(classpath.asPath)
186+
// }
187+
forkOptions.jvmArgs = listOf("--add-opens=java.desktop/java.awt=ALL-UNNAMED",
188+
"--add-opens=java.desktop/java.awt.event=ALL-UNNAMED",
189+
"--add-opens=java.desktop/sun.awt=ALL-UNNAMED",
190+
"--add-opens=java.desktop/sun.font=ALL-UNNAMED",
191+
"--add-opens=java.base/java.lang=ALL-UNNAMED",
192+
"-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader",
193+
"-Didea.mimic.jar.url.connection=true",
194+
"-Didea.force.use.core.classloader=true"
195+
)
196+
}
197+
168198
generateParser {
169199
source.set("src/main/gramar/clojure.bnf")
170200
targetRoot.set("src/gen")
@@ -180,14 +210,18 @@ tasks {
180210
}
181211
}
182212

213+
tasks.withType<Test>().configureEach {
214+
useJUnitPlatform()
215+
}
216+
183217
grammarKit {
184218
jflexRelease.set("1.7.0-1")
185219
grammarKitRelease.set("2021.1.2")
186220
intellijRelease.set("203.7717.81")
187221
}
188222

189223
clojure.builds.named("main") {
190-
classpath.from(sourceSets.main.get().runtimeClasspath.asPath)
224+
classpath.from(sourceSets.main.get().runtimeClasspath.asPath + "build/classes/kotlin/main")
191225
checkAll()
192226
aotAll()
193227
reflection.set("fail")

src/scripts/scripts.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
(shell "git push origin HEAD")
3636
(shell "git push origin --tags"))
3737

38+
(defn tests []
39+
(shell "./gradlew test"))
40+
3841
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
3942
(defn build-plugin []
4043
(shell "./gradlew buildPlugin"))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(ns com.github.clojure-lsp.intellij.foo-test
2+
(:require
3+
[clojure.test :refer [deftest is testing]]))
4+
5+
(set! *warn-on-reflection* true)
6+
7+
(deftest foo
8+
(testing "foo"
9+
(is false)))

0 commit comments

Comments
 (0)