Skip to content

Commit

Permalink
TS-34214 Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed May 3, 2023
1 parent 8cf82cb commit 3618b3b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/TestExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.get
import java.io.File

/** Determines the file under which the shadowJar task will store the final Teamscale JaCoCo Agent jar. */
val Test.agentJar: File
get() {
return project.project(":agent").tasks["shadowJar"].outputs.files.files.first()
return project.project(":agent").tasks["shadowJar"].outputs.files.singleFile
}

/** Adds a convenient way to attach the Teamscale JaCoCo agent to the test JVM with the given options in a readable map format. */
fun Test.teamscaleAgent(options: Map<String, String>) {
jvmArgs(
"-javaagent:$agentJar=${options.entries.joinToString(separator = ",") { "${it.key}=${it.value}" }}"
Expand Down
2 changes: 1 addition & 1 deletion system-tests/http-server-shutdown/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

tasks.test {
environment("AGENT_JAR", agentJar)
val sampleJar = project(":sample-app").tasks["jar"].outputs.files.files.first()
val sampleJar = project(":sample-app").tasks["jar"].outputs.files.singleFile
environment("SAMPLE_JAR", sampleJar)
dependsOn(":sample-app:assemble")
}
2 changes: 1 addition & 1 deletion system-tests/multiple-agents-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
}

tasks.test {
val otherJacocoAgent = jacocoAgent.files.first()
val otherJacocoAgent = jacocoAgent.singleFile
jvmArgs("-javaagent:$otherJacocoAgent")

val logFilePath = "logTest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.maybeCreate
import org.gradle.kotlin.dsl.withType
import org.gradle.testing.jacoco.plugins.JacocoPlugin
import org.gradle.testing.jacoco.tasks.JacocoReport
Expand Down Expand Up @@ -109,7 +110,7 @@ open class TeamscalePlugin : Plugin<Project> {
dependsOn.add(project.configurations.getByName(impactedTestEngineConfiguration))
}
val teamscaleReportTask = project.rootProject.tasks
.maybeCreate("${testImpactedTask.name}Report", TestwiseCoverageReportTask::class.java)
.maybeCreate<TestwiseCoverageReportTask>("${testImpactedTask.name}Report")
testImpactedTask.finalizedBy(teamscaleReportTask)
testImpactedTask.reportTask = teamscaleReportTask
teamscaleReportTask.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class AgentConfiguration(val project: Project, val jacocoExtension: JacocoTaskEx
val builder = StringBuilder()
val argument = ArgumentAppender(builder)
builder.append("-javaagent:")
val agentJar = project.configurations.getByName(TeamscalePlugin.teamscaleJaCoCoAgentConfiguration)
.filter { it.name.startsWith("teamscale-jacoco-agent") }.first()
val agentJar =
project.configurations.getByName(TeamscalePlugin.teamscaleJaCoCoAgentConfiguration).singleFile
builder.append(agentJar.canonicalPath)
builder.append("=")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import org.junit.jupiter.api.io.TempDir;
import java.io.File

/**
* You must run
* ./gradlew pluginUnderTestMetadata
* each time before running the tests in IntelliJ.
* Integration tests for the Teamscale Gradle plugin.
*/
class TeamscalePluginTest {

Expand All @@ -31,6 +29,7 @@ class TeamscalePluginTest {
private const val DEBUG_TEST_ENGINE = false
}

/** The temp dir in which the simulated checkout and test execution will happen. */
@field:TempDir
lateinit var temporaryFolder: File

Expand Down

0 comments on commit 3618b3b

Please sign in to comment.