From 883993818300a5cc46a67ca18636e936795c02e1 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Thu, 19 Nov 2015 14:48:56 +0300 Subject: [PATCH] Simplify lazy caches tests Original commit: c9012b10c56af609b2d4c5262d6b8cc2cb7dc6e6 --- .../jps/incremental/IncrementalCacheImpl.kt | 4 +++ .../AbstractIncrementalLazyCachesTest.kt | 30 +++++++++++-------- .../experimentalOn/expected-kotlin-caches.txt | 6 ++-- .../expected-kotlin-caches.txt | 6 ++-- .../expected-kotlin-caches.txt | 10 +++---- .../class/expected-kotlin-caches.txt | 4 +-- .../experimental-expected-kotlin-caches.txt | 4 +-- .../constant/expected-kotlin-caches.txt | 8 ++--- .../experimental-expected-kotlin-caches.txt | 8 ++--- .../function/expected-kotlin-caches.txt | 6 ++-- .../experimental-expected-kotlin-caches.txt | 6 ++-- .../expected-kotlin-caches.txt | 10 +++---- .../experimental-expected-kotlin-caches.txt | 10 +++---- .../expected-kotlin-caches.txt | 8 ++--- .../experimental-expected-kotlin-caches.txt | 8 ++--- .../expected-kotlin-caches.txt | 6 ++-- .../experimental-expected-kotlin-caches.txt | 6 ++-- 17 files changed, 75 insertions(+), 65 deletions(-) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt index 949b6ff31aa..e5bc9a750a6 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt @@ -54,6 +54,10 @@ import java.util.* internal val CACHE_DIRECTORY_NAME = "kotlin" +@TestOnly +public fun getCacheDirectoryName(): String = + CACHE_DIRECTORY_NAME + public class IncrementalCacheImpl( private val target: ModuleBuildTarget, paths: BuildDataPaths diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt index a20f9ae450c..26e4c9ee51a 100644 --- a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt +++ b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.config.IncrementalCompilation import org.jetbrains.kotlin.jps.incremental.CacheVersion import org.jetbrains.kotlin.jps.incremental.CacheVersionProvider import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget +import org.jetbrains.kotlin.jps.incremental.getCacheDirectoryName import org.jetbrains.kotlin.jps.incremental.storage.BasicMapsOwner import org.jetbrains.kotlin.utils.Printer import java.io.File @@ -86,41 +87,46 @@ public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJps val p = Printer(sb) val targets = projectDescriptor.allModuleTargets val paths = projectDescriptor.dataManager.dataPaths - val versionProvider = CacheVersionProvider(paths) + val versions = CacheVersionProvider(paths) - dumpCachesForTarget(p, paths, KotlinDataContainerTarget, versionProvider.dataContainerVersion()) + dumpCachesForTarget(p, paths, KotlinDataContainerTarget, versions.dataContainerVersion()) for (target in targets.sortedBy { it.presentableName }) { - dumpCachesForTarget(p, paths, target, versionProvider.normalVersion(target), versionProvider.experimentalVersion(target)) + dumpCachesForTarget(p, paths, target, versions.normalVersion(target), versions.experimentalVersion(target), + subdirectory = getCacheDirectoryName()) } return sb.toString() } - private fun dumpCachesForTarget(p: Printer, paths: BuildDataPaths, target: BuildTarget<*>, vararg cacheVersions: CacheVersion) { + private fun dumpCachesForTarget( + p: Printer, + paths: BuildDataPaths, + target: BuildTarget<*>, + vararg cacheVersions: CacheVersion, + subdirectory: String? = null + ) { p.println(target) p.pushIndent() - val dataRoot = paths.getTargetDataRoot(target) - + val dataRoot = paths.getTargetDataRoot(target).let { if (subdirectory != null) File(it, subdirectory) else it } cacheVersions .map { it.formatVersionFile } .filter { it.exists() } .sortedBy { it.name } - .forEach { p.println(it.relativeTo(dataRoot)) } + .forEach { p.println(it.name) } - val cacheNames = kotlinCacheNames(dataRoot) - cacheNames.sorted().forEach { p.println(it) } + kotlinCacheNames(dataRoot).sorted().forEach { p.println(it) } p.popIndent() } - private fun kotlinCacheNames(dataRoot: File): List { + private fun kotlinCacheNames(dir: File): List { val result = arrayListOf() - for (file in dataRoot.walk()) { + for (file in dir.walk()) { if (file.isFile && file.extension == BasicMapsOwner.CACHE_EXTENSION) { - result.add(file.relativeTo(dataRoot)) + result.add(file.name) } } diff --git a/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOn/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOn/expected-kotlin-caches.txt index 53e44e2f47f..670ef919aaa 100644 --- a/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOn/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOn/expected-kotlin-caches.txt @@ -7,7 +7,7 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnOff/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnOff/expected-kotlin-caches.txt index f689eecca42..45293da7039 100644 --- a/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnOff/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnOff/expected-kotlin-caches.txt @@ -1,7 +1,7 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/expected-kotlin-caches.txt index bb7db482263..744c17b4cdc 100644 --- a/jps/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/expected-kotlin-caches.txt @@ -1,9 +1,9 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/inline-functions.tab - kotlin/inlined-to.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + inline-functions.tab + inlined-to.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt index 9e89c6fabb6..cf4dcf7ea18 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt @@ -1,6 +1,6 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/proto.tab - kotlin/source-to-classes.tab + proto.tab + source-to-classes.tab Module 'module' tests \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/experimental-expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/experimental-expected-kotlin-caches.txt index 6eb14f15a36..b12e9b37962 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/experimental-expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/class/experimental-expected-kotlin-caches.txt @@ -7,6 +7,6 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/proto.tab - kotlin/source-to-classes.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt index ea990724ce0..9a851b0cc46 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt @@ -1,8 +1,8 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/constants.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + constants.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/experimental-expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/experimental-expected-kotlin-caches.txt index 161d898ca2e..dcd8748a3fa 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/experimental-expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/constant/experimental-expected-kotlin-caches.txt @@ -7,8 +7,8 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/constants.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + constants.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt index 91867b8ee16..8d3d53a48a1 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt @@ -1,7 +1,7 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/experimental-expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/experimental-expected-kotlin-caches.txt index 53e44e2f47f..670ef919aaa 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/experimental-expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/function/experimental-expected-kotlin-caches.txt @@ -7,7 +7,7 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/expected-kotlin-caches.txt index 92a6facecb5..3449f76e358 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/expected-kotlin-caches.txt @@ -1,9 +1,9 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/inline-functions.tab - kotlin/inlined-to.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + inline-functions.tab + inlined-to.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/experimental-expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/experimental-expected-kotlin-caches.txt index 63294672da5..62d125bf7f4 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/experimental-expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithUsage/experimental-expected-kotlin-caches.txt @@ -7,9 +7,9 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/inline-functions.tab - kotlin/inlined-to.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + inline-functions.tab + inlined-to.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/expected-kotlin-caches.txt index 0302fda6a81..ae521f0a275 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/expected-kotlin-caches.txt @@ -1,8 +1,8 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/inline-functions.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + inline-functions.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/experimental-expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/experimental-expected-kotlin-caches.txt index 62f7784a425..b947e922a24 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/experimental-expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionWithoutUsage/experimental-expected-kotlin-caches.txt @@ -7,8 +7,8 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/inline-functions.tab - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + inline-functions.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/expected-kotlin-caches.txt index 91867b8ee16..8d3d53a48a1 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/expected-kotlin-caches.txt @@ -1,7 +1,7 @@ kotlin-data-container Module 'module' production format-version.txt - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/experimental-expected-kotlin-caches.txt b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/experimental-expected-kotlin-caches.txt index 53e44e2f47f..670ef919aaa 100644 --- a/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/experimental-expected-kotlin-caches.txt +++ b/jps/jps-plugin/testData/incremental/lazyKotlinCaches/topLevelPropertyAccess/experimental-expected-kotlin-caches.txt @@ -7,7 +7,7 @@ kotlin-data-container Module 'module' production experimental-format-version.txt format-version.txt - kotlin/package-parts.tab - kotlin/proto.tab - kotlin/source-to-classes.tab + package-parts.tab + proto.tab + source-to-classes.tab Module 'module' tests