Skip to content

Commit

Permalink
Add the ability to run a testNg/testStreaming test on its own (#5338)
Browse files Browse the repository at this point in the history
Motivation:

Currently, `testNg` is run after `shadedTest` is run when the `check`
command is invoked.
However, even if there are updates to the source code, `testNg` won't
attempt to recompile the source code.
This can be easily reproduced by modifying a testNg class, and trying to
run `./gradlew testNg`.

This is because `testNg` currently depends on the classpath of
`shadedTest`. As long as `shadedTest` isn't invoked, the
`shadedTest.classpath` won't be updated.

Modifications:

- Since `copyShadedTestClasses` declares the test classpath as an input,
it is safe to rely on `copyShadedTestClasses` (just like `shadedTest`
does). Modified `testNg`, `testStreaming` to depend on
`copyShadedTestClasses` instead.
- Removed the `finalizedBy` dependency since it doesn't make sense to
have a dependency between `shadedTest` and `testNg`/`testStreaming`.

Result:

- We can run `./gradlew testNg` and receive results correctly

<!--
Visit this URL to learn more about how to write a pull request
description:

https://armeria.dev/community/developer-guide#how-to-write-pull-request-description
-->
  • Loading branch information
jrhee17 authored Jan 17, 2024
1 parent 20827c0 commit c4c6b3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 2 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ testing.suites {

project.ext.configureCommonTestSettings(it)

dependsOn(tasks.shadedTestClasses)
dependsOn(tasks.copyShadedTestClasses)
// Use small heap for streaming tests to quickly ensure we can stream the content larger than heap.
maxHeapSize = '64m'

Expand All @@ -201,7 +201,6 @@ testing.suites {
}
}
}
tasks.shadedTest.finalizedBy testing.suites.testStreaming
tasks.check.dependsOn testing.suites.testStreaming

// Run the test cases based on reactive-streams-tck only with non-flaky mode
Expand All @@ -215,7 +214,7 @@ if (rootProject.findProperty('flakyTests') != 'true') {

project.ext.configureCommonTestSettings(it)
include '/com/linecorp/armeria/**/common/**'
dependsOn tasks.shadedTestClasses
dependsOn tasks.copyShadedTestClasses
scanForTestClasses = false
testClassesDirs = tasks.shadedTest.testClassesDirs
classpath = testClassesDirs
Expand All @@ -229,7 +228,6 @@ if (rootProject.findProperty('flakyTests') != 'true') {
}
}
}
tasks.shadedTest.finalizedBy testing.suites.testNg
tasks.check.dependsOn testing.suites.testNg
}

Expand Down
8 changes: 7 additions & 1 deletion kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ testing {
testTask.configure {
group = "Verification"
description = "Runs the TestNG unit tests"
dependsOn(tasks.copyShadedTestClasses)
val shadedTestTask = tasks.shadedTest.get()
testClassesDirs = shadedTestTask.testClassesDirs
classpath = shadedTestTask.testClassesDirs
doFirst {
classpath += project.files(configurations.shadedJarTestRuntime.get().resolve())
}
}
}
}
Expand All @@ -39,5 +46,4 @@ testing {
}
}

tasks.shadedTest { finalizedBy(testing.suites.named("testNg")) }
tasks.check { dependsOn(testing.suites.named("testNg")) }

0 comments on commit c4c6b3d

Please sign in to comment.