tests(tooling-api): do add unresolved dependency when config cache is enabled

This commit is contained in:
Akash Yadav
2023-10-05 20:22:31 +05:30
parent 5562dc2069
commit 18ad0fb0e5
3 changed files with 17 additions and 3 deletions
@@ -59,7 +59,9 @@ class MultiModuleAndroidProjectTest {
// Issue #1173
val taskPaths = mutableListOf<String>()
val client = object : MultiVersionTestClient() {
// do not add unresolved dependency so that teh configuration cache is properly created
val client = object : MultiVersionTestClient(excludeUnresolvedDependency = true) {
override fun getBuildArguments(): CompletableFuture<List<String>> {
return CompletableFuture.completedFuture(super.getBuildArguments().get().toMutableList()
@@ -128,7 +128,8 @@ class ToolingApiTestLauncher {
var agpVersion: String = DEFAULT_AGP_VERSION,
var gradleVersion: String = DEFAULT_GRADLE_VERSION,
private val log: ILogger = ILogger.newInstance(MultiVersionTestClient::class.simpleName),
private val extraArgs : List<String> = emptyList()
private val extraArgs : List<String> = emptyList(),
private var excludeUnresolvedDependency: Boolean = false
) : IToolingApiClient {
val gradleDistParams: GradleDistributionParams
@@ -139,6 +140,9 @@ class ToolingApiTestLauncher {
const val buildFile = "build.gradle"
const val buildFileIn = "$buildFile.in"
const val appBuildFile = "app/build.gradle"
const val appBuildFileIn = "$appBuildFile.in"
const val DEFAULT_AGP_VERSION = "7.2.0"
const val DEFAULT_GRADLE_VERSION = "7.3.3"
@@ -163,6 +167,12 @@ class ToolingApiTestLauncher {
projectDir.resolve(buildFileIn)
.replaceContents(dest = projectDir.resolve(buildFile),
candidate = "@@TOOLING_API_TEST_AGP_VERSION@@" to this.agpVersion)
if (!excludeUnresolvedDependency) {
projectDir.resolve(appBuildFileIn)
.replaceContents(dest = projectDir.resolve(appBuildFile),
candidate = "@@UNRESOLVED_DEPENDENCY@@" to "implementation 'unresolved:unresolved:unresolved'")
}
}
override fun onBuildSuccessful(result: BuildResult) {
@@ -175,6 +185,7 @@ class ToolingApiTestLauncher {
private fun onBuildResult(result: BuildResult) {
projectDir.resolve(buildFile).deleteIfExists()
projectDir.resolve(appBuildFile).deleteIfExists()
}
override fun onProgressEvent(event: ProgressEvent) {}