Pārlūkot izejas kodu

Convert log4j test to test suites (#7942)

Part of
https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/7911
Lauri Tulmin 2 gadi atpakaļ
vecāks
revīzija
f8927a45b2

+ 26 - 14
instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/javaagent/build.gradle.kts

@@ -1,6 +1,5 @@
 plugins {
   id("otel.javaagent-instrumentation")
-  id("org.unbroken-dome.test-sets")
 }
 
 muzzle {
@@ -12,14 +11,6 @@ muzzle {
   }
 }
 
-testSets {
-  // Very different codepaths when threadlocals are enabled or not so we check both.
-  // Regression test for https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2403
-  create("testDisableThreadLocals") {
-    dirName = "test"
-  }
-}
-
 dependencies {
   library("org.apache.logging.log4j:log4j-core:2.17.0")
 
@@ -30,12 +21,33 @@ dependencies {
   testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
 }
 
-tasks {
-  val testDisableThreadLocals by existing(Test::class) {
-    jvmArgs("-Dlog4j2.is.webapp=false")
-    jvmArgs("-Dlog4j2.enable.threadlocals=false")
+testing {
+  suites {
+    // Very different codepaths when threadlocals are enabled or not so we check both.
+    // Regression test for https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2403
+    val testDisableThreadLocals by registering(JvmTestSuite::class) {
+      sources {
+        groovy {
+          setSrcDirs(listOf("src/test/groovy"))
+        }
+      }
+      dependencies {
+        implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
+      }
+
+      targets {
+        all {
+          testTask.configure {
+            jvmArgs("-Dlog4j2.is.webapp=false")
+            jvmArgs("-Dlog4j2.enable.threadlocals=false")
+          }
+        }
+      }
+    }
   }
+}
 
+tasks {
   // Threadlocals are always false if is.webapp is true, so we make sure to override it because as of
   // now testing-common includes jetty / servlet.
   test {
@@ -44,6 +56,6 @@ tasks {
   }
 
   named("check") {
-    dependsOn(testDisableThreadLocals)
+    dependsOn(testing.suites)
   }
 }