New IC: Reorganize test data directories

to make it easier to add new tests

^KT-53266 In progress
This commit is contained in:
Hung Nguyen
2022-07-28 15:58:21 +01:00
committed by Alexander Likhachev
parent fd4aafdb75
commit 3f0a93d6dd
141 changed files with 28 additions and 24 deletions
@@ -38,14 +38,14 @@ abstract class ClasspathChangesComputerTest : ClasspathSnapshotTestCommon() {
abstract fun testMixedClassSnapshotGranularities() abstract fun testMixedClassSnapshotGranularities()
@Test @Test
abstract fun testImpactAnalysis() abstract fun testImpactComputation_SupertypesInheritors()
} }
class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() { class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testAbiVersusNonAbiChanges() { override fun testAbiVersusNonAbiChanges() {
val changes = computeClasspathChanges(File(testDataDir, "testAbiVersusNonAbiChanges/src/kotlin"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testAbiVersusNonAbiChanges/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "publicPropertyChangedType", scope = "com.example.SomeClass"), LookupSymbol(name = "publicPropertyChangedType", scope = "com.example.SomeClass"),
@@ -58,7 +58,7 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testModifiedAddedRemovedElements() { override fun testModifiedAddedRemovedElements() {
val changes = computeClasspathChanges(File(testDataDir, "testModifiedAddedRemovedElements/src/kotlin"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testModifiedAddedRemovedElements/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
// ModifiedClassUnchangedMembers // ModifiedClassUnchangedMembers
@@ -90,7 +90,7 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testModifiedAddedRemovedElements_ClassLevelSnapshot() { override fun testModifiedAddedRemovedElements_ClassLevelSnapshot() {
val changes = computeClasspathChanges(File(testDataDir, "testModifiedAddedRemovedElements/src/kotlin"), tmpDir, CLASS_LEVEL) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testModifiedAddedRemovedElements/src"), tmpDir, CLASS_LEVEL)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "ModifiedClassUnchangedMembers", scope = "com.example"), LookupSymbol(name = "ModifiedClassUnchangedMembers", scope = "com.example"),
@@ -109,8 +109,8 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testMixedClassSnapshotGranularities() { override fun testMixedClassSnapshotGranularities() {
val currentClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("kotlin", "current-classpath", tmpDir) val currentClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("KotlinOnly", "current-classpath", tmpDir)
val previousClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("kotlin", "previous-classpath", tmpDir) val previousClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("KotlinOnly", "previous-classpath", tmpDir)
val changes = computeClasspathChanges(currentClasspathSnapshot, previousClasspathSnapshot) val changes = computeClasspathChanges(currentClasspathSnapshot, previousClasspathSnapshot)
Changes( Changes(
@@ -132,8 +132,8 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
} }
@Test @Test
override fun testImpactAnalysis() { override fun testImpactComputation_SupertypesInheritors() {
val changes = computeClasspathChanges(File(testDataDir, "testImpactAnalysis_KotlinOnly/src"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testImpactComputation_SupertypesInheritors/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "changedProperty", scope = "com.example.ChangedSuperClass"), LookupSymbol(name = "changedProperty", scope = "com.example.ChangedSuperClass"),
@@ -156,7 +156,7 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
fun testTopLevelMembers() { fun testTopLevelMembers() {
val changes = computeClasspathChanges(File(testDataDir, "testTopLevelMembers_KotlinOnly/src"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testTopLevelMembers/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "modifiedTopLevelProperty", scope = "com.example"), LookupSymbol(name = "modifiedTopLevelProperty", scope = "com.example"),
@@ -174,7 +174,7 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
fun testDifferentClassKinds() { fun testDifferentClassKinds() {
val changes = computeClasspathChanges(File(testDataDir, "testDifferentClassKinds_KotlinOnly/src"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testDifferentClassKinds/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
// NormalClass // NormalClass
@@ -214,7 +214,7 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
fun testConstantsAndInlineFunctions() { fun testConstantsAndInlineFunctions() {
val changes = computeClasspathChanges(File(testDataDir, "testConstantsAndInlineFunctions_KotlinOnly/src"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testConstantsAndInlineFunctions/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "constantChangedType", scope = "com.example.SomeClass.CompanionObject"), LookupSymbol(name = "constantChangedType", scope = "com.example.SomeClass.CompanionObject"),
@@ -238,7 +238,7 @@ class JavaOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testAbiVersusNonAbiChanges() { override fun testAbiVersusNonAbiChanges() {
val changes = computeClasspathChanges(File(testDataDir, "testAbiVersusNonAbiChanges/src/java"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "JavaOnly/testAbiVersusNonAbiChanges/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "publicFieldChangedType", scope = "com.example.SomeClass"), LookupSymbol(name = "publicFieldChangedType", scope = "com.example.SomeClass"),
@@ -251,7 +251,7 @@ class JavaOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testModifiedAddedRemovedElements() { override fun testModifiedAddedRemovedElements() {
val changes = computeClasspathChanges(File(testDataDir, "testModifiedAddedRemovedElements/src/java"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "JavaOnly/testModifiedAddedRemovedElements/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
// ModifiedClassUnchangedMembers // ModifiedClassUnchangedMembers
@@ -283,7 +283,7 @@ class JavaOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testModifiedAddedRemovedElements_ClassLevelSnapshot() { override fun testModifiedAddedRemovedElements_ClassLevelSnapshot() {
val changes = computeClasspathChanges(File(testDataDir, "testModifiedAddedRemovedElements/src/java"), tmpDir, CLASS_LEVEL) val changes = computeClasspathChanges(File(testDataDir, "JavaOnly/testModifiedAddedRemovedElements/src"), tmpDir, CLASS_LEVEL)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "ModifiedClassUnchangedMembers", scope = "com.example"), LookupSymbol(name = "ModifiedClassUnchangedMembers", scope = "com.example"),
@@ -302,8 +302,8 @@ class JavaOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
@Test @Test
override fun testMixedClassSnapshotGranularities() { override fun testMixedClassSnapshotGranularities() {
val currentClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("java", "current-classpath", tmpDir) val currentClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("JavaOnly", "current-classpath", tmpDir)
val previousClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("java", "previous-classpath", tmpDir) val previousClasspathSnapshot = testMixedClassSnapshotGranularities_snapshotClasspath("JavaOnly", "previous-classpath", tmpDir)
val changes = computeClasspathChanges(currentClasspathSnapshot, previousClasspathSnapshot) val changes = computeClasspathChanges(currentClasspathSnapshot, previousClasspathSnapshot)
Changes( Changes(
@@ -325,8 +325,8 @@ class JavaOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
} }
@Test @Test
override fun testImpactAnalysis() { override fun testImpactComputation_SupertypesInheritors() {
val changes = computeClasspathChanges(File(testDataDir, "testImpactAnalysis_JavaOnly/src"), tmpDir) val changes = computeClasspathChanges(File(testDataDir, "JavaOnly/testImpactComputation_SupertypesInheritors/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "changedField", scope = "com.example.ChangedSuperClass"), LookupSymbol(name = "changedField", scope = "com.example.ChangedSuperClass"),
@@ -354,9 +354,8 @@ class KotlinAndJavaClasspathChangesComputerTest : ClasspathSnapshotTestCommon()
// - Java class converted to Kotlin class // - Java class converted to Kotlin class
@Test @Test
fun testImpactAnalysis() { fun testImpactComputation_SupertypesInheritors() {
val changes = val changes = computeClasspathChanges(File(testDataDir, "KotlinAndJava/testImpactComputation_SupertypesInheritors/src"), tmpDir)
computeClasspathChanges(File(testDataDir, "testImpactAnalysis_KotlinAndJava/src"), tmpDir)
Changes( Changes(
lookupSymbols = setOf( lookupSymbols = setOf(
LookupSymbol(name = "changedProperty", scope = "com.example.ChangedKotlinSuperClass"), LookupSymbol(name = "changedProperty", scope = "com.example.ChangedKotlinSuperClass"),
@@ -393,7 +392,7 @@ class KotlinAndJavaClasspathChangesComputerTest : ClasspathSnapshotTestCommon()
private fun testMixedClassSnapshotGranularities_snapshotClasspath( private fun testMixedClassSnapshotGranularities_snapshotClasspath(
language: String, classpathSourceDirName: String, tmpDir: TemporaryFolder language: String, classpathSourceDirName: String, tmpDir: TemporaryFolder
): ClasspathSnapshot { ): ClasspathSnapshot {
val classes = compileAll(File("$testDataDir/testMixedClassSnapshotGranularities/src/$language/$classpathSourceDirName/0"), tmpDir) val classes = compileAll(File("$testDataDir/$language/testMixedClassSnapshotGranularities/src/$classpathSourceDirName"), tmpDir)
fun getGranularity(classFile: ClassFile): ClassSnapshotGranularity { fun getGranularity(classFile: ClassFile): ClassSnapshotGranularity {
val granularity = when (val className = classFile.asFile().nameWithoutExtension) { val granularity = when (val className = classFile.asFile().nameWithoutExtension) {
@@ -100,7 +100,7 @@ abstract class ClasspathSnapshotTestCommon {
* Kotlin compiler to generate classes. However, kotlin-compiler.jar is currently not available in CI builds, so we need to * Kotlin compiler to generate classes. However, kotlin-compiler.jar is currently not available in CI builds, so we need to
* pre-compile the classes locally and put them in the test data to check in. * pre-compile the classes locally and put them in the test data to check in.
*/ */
@Synchronized // To safe-guard shared variable preCompiledKotlinClassesDirs @Synchronized // To safeguard shared variable preCompiledKotlinClassesDirs
private fun preCompileKotlinFilesIfNecessary( private fun preCompileKotlinFilesIfNecessary(
srcDir: File, srcDir: File,
preCompiledKotlinClassesDir: File, preCompiledKotlinClassesDir: File,
@@ -195,7 +195,12 @@ internal fun snapshotClasspath(
granularity: ClassSnapshotGranularity? = null granularity: ClassSnapshotGranularity? = null
): ClasspathSnapshot { ): ClasspathSnapshot {
val classpath = mutableListOf<File>() val classpath = mutableListOf<File>()
val classpathEntrySnapshots = classpathSourceDir.listFiles()!!.sortedBy { it.name }.map { classpathEntrySourceDir -> val classpathEntrySourceDirs = if (classpathSourceDir.listFiles()!!.size == 1) {
listOf(classpathSourceDir)
} else {
classpathSourceDir.listFiles()!!.sortedBy { it.name }
}
val classpathEntrySnapshots = classpathEntrySourceDirs.map { classpathEntrySourceDir ->
val classFiles = compileAll(classpathEntrySourceDir, tmpDir, classpath) val classFiles = compileAll(classpathEntrySourceDir, tmpDir, classpath)
classpath.addAll(listOfNotNull(classFiles.firstOrNull()?.classRoot)) classpath.addAll(listOfNotNull(classFiles.firstOrNull()?.classRoot))

Some files were not shown because too many files have changed in this diff Show More