Skip to content

Commit 2f12bf5

Browse files
committed
Convert runtime-attach to use test suites
1 parent ac7d80d commit 2f12bf5

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

runtime-attach/runtime-attach/build.gradle.kts

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,48 @@ dependencies {
2424
testImplementation("org.assertj:assertj-core")
2525
}
2626

27+
testing {
28+
suites {
29+
val test by getting(JvmTestSuite::class) {
30+
targets.all {
31+
testTask.configure {
32+
setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
33+
filter {
34+
excludeTestsMatching("AgentDisabledByEnvironmentVariableTest")
35+
excludeTestsMatching("AgentDisabledBySystemPropertyTest")
36+
}
37+
}
38+
}
39+
}
40+
41+
val testAgentDisabledByEnvironmentVariable by registering(JvmTestSuite::class) {
42+
targets.all {
43+
testTask.configure {
44+
setForkEvery(1)
45+
filter {
46+
includeTestsMatching("AgentDisabledByEnvironmentVariableTest")
47+
}
48+
include("**/AgentDisabledByEnvironmentVariableTest.*")
49+
environment("OTEL_JAVAAGENT_ENABLED", "false")
50+
}
51+
}
52+
}
53+
54+
val testAgentDisabledBySystemProperty by registering(JvmTestSuite::class) {
55+
targets.all {
56+
testTask.configure {
57+
setForkEvery(1)
58+
filter {
59+
includeTestsMatching("AgentDisabledBySystemPropertyTest")
60+
}
61+
include("**/AgentDisabledBySystemPropertyTest.*")
62+
jvmArgs("-Dotel.javaagent.enabled=false")
63+
}
64+
}
65+
}
66+
}
67+
}
68+
2769
tasks {
2870
jar {
2971
inputs.files(agent)
@@ -33,35 +75,7 @@ tasks {
3375
rename("^(.*)\\.jar\$", "otel-agent.jar")
3476
}
3577

36-
withType<Test>().configureEach {
37-
setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
38-
}
39-
40-
val testAgentDisabledByEnvironmentVariable by registering(Test::class) {
41-
filter {
42-
includeTestsMatching("AgentDisabledByEnvironmentVariableTest")
43-
}
44-
include("**/AgentDisabledByEnvironmentVariableTest.*")
45-
environment("OTEL_JAVAAGENT_ENABLED", "false")
46-
}
47-
48-
val testAgentDisabledBySystemProperty by registering(Test::class) {
49-
filter {
50-
includeTestsMatching("AgentDisabledBySystemPropertyTest")
51-
}
52-
include("**/AgentDisabledBySystemPropertyTest.*")
53-
jvmArgs("-Dotel.javaagent.enabled=false")
54-
}
55-
56-
test {
57-
filter {
58-
excludeTestsMatching("AgentDisabledByEnvironmentVariableTest")
59-
excludeTestsMatching("AgentDisabledBySystemPropertyTest")
60-
}
61-
}
62-
6378
check {
64-
dependsOn(testAgentDisabledByEnvironmentVariable)
65-
dependsOn(testAgentDisabledBySystemProperty)
79+
dependsOn(testing.suites)
6680
}
6781
}

0 commit comments

Comments
 (0)