Refactor Infrastructure of IC tests
1) Move root util functions to separate CompileRunnerUtils file from IncrementalJvmCompileRunner to leave the only class instance there and to separate util functions 2) Move TestLookupTracker from the abstract parent class location to a separate file as an implementation class 3) Small change naming of building functions just to clarify what they do 4) Some small code-style refactorings
This commit is contained in:
committed by
Space Team
parent
02abafd98d
commit
ae8428e8d0
+6
-4
@@ -36,9 +36,10 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
|
||||
|
||||
protected open fun resetTest(testDir: File, newOutDir: File, newCacheDir: File) {}
|
||||
|
||||
private fun createCompilerArgumentsImpl(destinationDir: File, testDir: File): Args = createCompilerArguments(destinationDir, testDir).apply {
|
||||
parseCommandLineArguments(parseAdditionalArgs(testDir), this)
|
||||
}
|
||||
private fun createCompilerArgumentsImpl(destinationDir: File, testDir: File): Args =
|
||||
createCompilerArguments(destinationDir, testDir).apply {
|
||||
parseCommandLineArguments(parseAdditionalArgs(testDir), this)
|
||||
}
|
||||
|
||||
fun doTest(path: String) {
|
||||
val testDir = File(path)
|
||||
@@ -127,7 +128,8 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
|
||||
// these functions are needed only to simplify debugging of IC tests
|
||||
private fun initialMake(cacheDir: File, outDir: File, sourceRoots: List<File>, args: Args) = make(cacheDir, outDir, sourceRoots, args)
|
||||
|
||||
private fun incrementalMake(cacheDir: File, outDir: File, sourceRoots: List<File>, args: Args) = make(cacheDir, outDir, sourceRoots, args)
|
||||
private fun incrementalMake(cacheDir: File, outDir: File, sourceRoots: List<File>, args: Args) =
|
||||
make(cacheDir, outDir, sourceRoots, args)
|
||||
|
||||
protected open fun rebuildAndCompareOutput(
|
||||
sourceRoots: List<File>,
|
||||
|
||||
+5
-4
@@ -30,7 +30,7 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
|
||||
override fun make(cacheDir: File, outDir: File, sourceRoots: Iterable<File>, args: K2JVMCompilerArguments): TestCompilationResult {
|
||||
val reporter = TestICReporter()
|
||||
val messageCollector = TestMessageCollector()
|
||||
makeIncrementally(cacheDir, sourceRoots, args, reporter = reporter, messageCollector = messageCollector)
|
||||
makeJvmIncrementally(cacheDir, sourceRoots, args, reporter = reporter, messageCollector = messageCollector)
|
||||
val kotlinCompileResult = TestCompilationResult(reporter, messageCollector)
|
||||
if (kotlinCompileResult.exitCode != ExitCode.OK) return kotlinCompileResult
|
||||
|
||||
@@ -55,9 +55,10 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
|
||||
}
|
||||
mkdirs()
|
||||
}
|
||||
val args = arrayOf("-cp", javaClasspath,
|
||||
"-d", javaDestinationDir.canonicalPath,
|
||||
*javaSources.map { it.canonicalPath }.toTypedArray()
|
||||
val args = arrayOf(
|
||||
"-cp", javaClasspath,
|
||||
"-d", javaDestinationDir.canonicalPath,
|
||||
*javaSources.map { it.canonicalPath }.toTypedArray()
|
||||
)
|
||||
|
||||
val err = ByteArrayOutputStream()
|
||||
|
||||
+1
-2
@@ -30,8 +30,7 @@ class TestICReporter : ICReporterBase() {
|
||||
var exitCode: ExitCode = ExitCode.OK
|
||||
private set
|
||||
|
||||
override fun report(message: () -> String, severity: ReportSeverity) {
|
||||
}
|
||||
override fun report(message: () -> String, severity: ReportSeverity) {}
|
||||
|
||||
override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
compiledSourcesMutable.addAll(sourceFiles)
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.incremental.utils
|
||||
|
||||
import com.intellij.util.containers.Interner
|
||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||
import org.jetbrains.kotlin.incremental.components.LookupInfo
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.components.Position
|
||||
import org.jetbrains.kotlin.incremental.components.ScopeKind
|
||||
|
||||
class TestLookupTracker(val savedLookups: MutableSet<LookupSymbol> = mutableSetOf()) : LookupTracker {
|
||||
val lookups = arrayListOf<LookupInfo>()
|
||||
private val interner = Interner.createStringInterner()
|
||||
|
||||
override val requiresPosition: Boolean
|
||||
get() = true
|
||||
|
||||
override fun record(filePath: String, position: Position, scopeFqName: String, scopeKind: ScopeKind, name: String) {
|
||||
val internedFilePath = interner.intern(filePath)
|
||||
val internedScopeFqName = interner.intern(scopeFqName)
|
||||
val internedName = interner.intern(name)
|
||||
|
||||
lookups.add(LookupInfo(internedFilePath, position, internedScopeFqName, scopeKind, internedName))
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
lookups.clear()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user