[Native][tests] Unify work with build directories across BB & Simple tests
* Drop 'SimpleTestDirectories' in favor of 'Binaries' * Make 'Binaries' lazy
This commit is contained in:
committed by
Space Team
parent
f7848133a6
commit
82984d782a
+2
-2
@@ -17,9 +17,9 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilati
|
|||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.group.UsePartialLinkage
|
import org.jetbrains.kotlin.konan.blackboxtest.support.group.UsePartialLinkage
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestExecutable
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestExecutable
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Binaries
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.SimpleTestDirectories
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
||||||
import org.jetbrains.kotlin.test.Directives
|
import org.jetbrains.kotlin.test.Directives
|
||||||
@@ -284,7 +284,7 @@ abstract class AbstractNativeKlibEvolutionTest : AbstractNativeSimpleTest() {
|
|||||||
initialize(null, null)
|
initialize(null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val buildDir: File get() = testRunSettings.get<SimpleTestDirectories>().testBuildDir
|
private val buildDir: File get() = testRunSettings.get<Binaries>().testBinariesDir
|
||||||
private val useStaticCacheForUserLibraries: Boolean get() = testRunSettings.get<CacheMode>().useStaticCacheForUserLibraries
|
private val useStaticCacheForUserLibraries: Boolean get() = testRunSettings.get<CacheMode>().useStaticCacheForUserLibraries
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+1
-1
@@ -213,7 +213,7 @@ abstract class AbstractNativePartialLinkageTest : AbstractNativeSimpleTest() {
|
|||||||
klib = this
|
klib = this
|
||||||
)
|
)
|
||||||
|
|
||||||
private val buildDir: File get() = testRunSettings.get<SimpleTestDirectories>().testBuildDir
|
private val buildDir: File get() = testRunSettings.get<Binaries>().testBinariesDir
|
||||||
private val stdlibFile: File get() = testRunSettings.get<KotlinNativeHome>().stdlibFile
|
private val stdlibFile: File get() = testRunSettings.get<KotlinNativeHome>().stdlibFile
|
||||||
private val useStaticCacheForUserLibraries: Boolean get() = testRunSettings.get<CacheMode>().useStaticCacheForUserLibraries
|
private val useStaticCacheForUserLibraries: Boolean get() = testRunSettings.get<CacheMode>().useStaticCacheForUserLibraries
|
||||||
|
|
||||||
|
|||||||
+4
-19
@@ -6,29 +6,14 @@
|
|||||||
package org.jetbrains.kotlin.konan.blackboxtest
|
package org.jetbrains.kotlin.konan.blackboxtest
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.PackageName
|
import org.jetbrains.kotlin.konan.blackboxtest.support.*
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase
|
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.*
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCaseId
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestDirectives
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestFile
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestRunnerType
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExecutableCompilation
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExistingDependency
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.LibraryCompilation
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.StaticCacheCompilation
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationDependency
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationDependencyType
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestExecutable
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestExecutable
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Binaries
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.PipelineType
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.PipelineType
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.SimpleTestDirectories
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.LAUNCHER_MODULE_NAME
|
import org.jetbrains.kotlin.konan.blackboxtest.support.util.LAUNCHER_MODULE_NAME
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
@@ -114,7 +99,7 @@ internal class ExecutableBuilder(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val AbstractNativeSimpleTest.buildDir: File get() = testRunSettings.get<SimpleTestDirectories>().testBuildDir
|
internal val AbstractNativeSimpleTest.buildDir: File get() = testRunSettings.get<Binaries>().testBinariesDir
|
||||||
|
|
||||||
internal fun TestCompilationArtifact.KLIB.asLibraryDependency() =
|
internal fun TestCompilationArtifact.KLIB.asLibraryDependency() =
|
||||||
ExistingDependency(this, TestCompilationDependencyType.Library)
|
ExistingDependency(this, TestCompilationDependencyType.Library)
|
||||||
|
|||||||
+21
-15
@@ -207,7 +207,6 @@ private object NativeTestSupport {
|
|||||||
output += computePipelineType(testClass.get())
|
output += computePipelineType(testClass.get())
|
||||||
output += computeUsedPartialLinkageConfig(enclosingTestClass)
|
output += computeUsedPartialLinkageConfig(enclosingTestClass)
|
||||||
output += computeCompilerOutputInterceptor(enforcedProperties)
|
output += computeCompilerOutputInterceptor(enforcedProperties)
|
||||||
output += computeBinariesDirs(getOrCreateTestProcessSettings().get(), nativeTargets, enclosingTestClass)
|
|
||||||
|
|
||||||
return nativeTargets
|
return nativeTargets
|
||||||
}
|
}
|
||||||
@@ -338,6 +337,7 @@ private object NativeTestSupport {
|
|||||||
|
|
||||||
// Put settings that are always required:
|
// Put settings that are always required:
|
||||||
this += computedTestConfiguration
|
this += computedTestConfiguration
|
||||||
|
this += computeBinariesForBlackBoxTests(testProcessSettings.get(), nativeTargets, enclosingTestClass)
|
||||||
|
|
||||||
// Add custom settings:
|
// Add custom settings:
|
||||||
computedTestConfiguration.configuration.requiredSettings.forEach { clazz ->
|
computedTestConfiguration.configuration.requiredSettings.forEach { clazz ->
|
||||||
@@ -435,21 +435,22 @@ private object NativeTestSupport {
|
|||||||
return GeneratedSources(testSourcesDir, sharedSourcesDir)
|
return GeneratedSources(testSourcesDir, sharedSourcesDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun computeBinariesDirs(baseDirs: BaseDirs, targets: KotlinNativeTargets, enclosingTestClass: Class<*>): Binaries {
|
/** See also [computeBinariesForSimpleTests] */
|
||||||
|
private fun computeBinariesForBlackBoxTests(
|
||||||
|
baseDirs: BaseDirs,
|
||||||
|
targets: KotlinNativeTargets,
|
||||||
|
enclosingTestClass: Class<*>
|
||||||
|
): Binaries {
|
||||||
val testBinariesDir = baseDirs.testBuildDir
|
val testBinariesDir = baseDirs.testBuildDir
|
||||||
.resolve("bb.out") // "bb" for black box
|
.resolve("bb.out") // "bb" for black box
|
||||||
.resolve("${targets.testTarget.compressedName}_${enclosingTestClass.compressedSimpleName}")
|
.resolve("${targets.testTarget.compressedName}_${enclosingTestClass.compressedSimpleName}")
|
||||||
.ensureExistsAndIsEmptyDirectory() // Clean-up the directory with all potentially stale artifacts.
|
.ensureExistsAndIsEmptyDirectory() // Clean-up the directory with all potentially stale artifacts.
|
||||||
|
|
||||||
val sharedBinariesDir = testBinariesDir
|
return Binaries(
|
||||||
.resolve(SHARED_MODULES_DIR_NAME)
|
testBinariesDir = testBinariesDir,
|
||||||
.ensureExistsAndIsEmptyDirectory()
|
lazySharedBinariesDir = { testBinariesDir.resolve(SHARED_MODULES_DIR_NAME).ensureExistsAndIsEmptyDirectory() },
|
||||||
|
lazyGivenBinariesDir = { testBinariesDir.resolve(GIVEN_MODULES_DIR_NAME).ensureExistsAndIsEmptyDirectory() }
|
||||||
val givenBinariesDir = testBinariesDir
|
)
|
||||||
.resolve(GIVEN_MODULES_DIR_NAME)
|
|
||||||
.ensureExistsAndIsEmptyDirectory()
|
|
||||||
|
|
||||||
return Binaries(testBinariesDir, sharedBinariesDir, givenBinariesDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun computePipelineType(testClass: Class<*>): PipelineType {
|
private fun computePipelineType(testClass: Class<*>): PipelineType {
|
||||||
@@ -515,23 +516,28 @@ private object NativeTestSupport {
|
|||||||
parent = testClassSettings,
|
parent = testClassSettings,
|
||||||
listOf(
|
listOf(
|
||||||
computeSimpleTestInstances(),
|
computeSimpleTestInstances(),
|
||||||
computeSimpleTestDirectories(testClassSettings.get(), testClassSettings.get())
|
computeBinariesForSimpleTests(testClassSettings.get(), testClassSettings.get())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ExtensionContext.computeSimpleTestInstances(): SimpleTestInstances = SimpleTestInstances(requiredTestInstances.allInstances)
|
private fun ExtensionContext.computeSimpleTestInstances(): SimpleTestInstances = SimpleTestInstances(requiredTestInstances.allInstances)
|
||||||
|
|
||||||
private fun ExtensionContext.computeSimpleTestDirectories(baseDirs: BaseDirs, targets: KotlinNativeTargets): SimpleTestDirectories {
|
/** See also [computeBinariesForBlackBoxTests] */
|
||||||
|
private fun ExtensionContext.computeBinariesForSimpleTests(baseDirs: BaseDirs, targets: KotlinNativeTargets): Binaries {
|
||||||
val compressedClassNames = testClasses.map(Class<*>::compressedSimpleName).joinToString(separator = "_")
|
val compressedClassNames = testClasses.map(Class<*>::compressedSimpleName).joinToString(separator = "_")
|
||||||
|
|
||||||
val testBuildDir = baseDirs.testBuildDir
|
val testBinariesDir = baseDirs.testBuildDir
|
||||||
.resolve("s") // "s" for simple
|
.resolve("s") // "s" for simple
|
||||||
.resolve("${targets.testTarget.compressedName}_$compressedClassNames")
|
.resolve("${targets.testTarget.compressedName}_$compressedClassNames")
|
||||||
.resolve(requiredTestMethod.name)
|
.resolve(requiredTestMethod.name)
|
||||||
.ensureExistsAndIsEmptyDirectory() // Clean-up the directory with all potentially stale artifacts.
|
.ensureExistsAndIsEmptyDirectory() // Clean-up the directory with all potentially stale artifacts.
|
||||||
|
|
||||||
return SimpleTestDirectories(testBuildDir)
|
return Binaries(
|
||||||
|
testBinariesDir = testBinariesDir,
|
||||||
|
lazySharedBinariesDir = { testBinariesDir.resolve(SHARED_MODULES_DIR_NAME).ensureExistsAndIsEmptyDirectory() },
|
||||||
|
lazyGivenBinariesDir = { testBinariesDir.resolve(GIVEN_MODULES_DIR_NAME).ensureExistsAndIsEmptyDirectory() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************** Test run provider (for black box tests only) ***************/
|
/*************** Test run provider (for black box tests only) ***************/
|
||||||
|
|||||||
-8
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.konan.blackboxtest.support.settings
|
package org.jetbrains.kotlin.konan.blackboxtest.support.settings
|
||||||
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.AbstractNativeSimpleTest
|
import org.jetbrains.kotlin.konan.blackboxtest.AbstractNativeSimpleTest
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All instances of test classes.
|
* All instances of test classes.
|
||||||
@@ -18,10 +17,3 @@ internal class SimpleTestInstances(val allInstances: List<Any>) {
|
|||||||
val enclosingTestInstance: AbstractNativeSimpleTest
|
val enclosingTestInstance: AbstractNativeSimpleTest
|
||||||
get() = allInstances.firstOrNull() as AbstractNativeSimpleTest
|
get() = allInstances.firstOrNull() as AbstractNativeSimpleTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The build directory specifically for the current test function.
|
|
||||||
*/
|
|
||||||
internal class SimpleTestDirectories(val testBuildDir: File)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -26,7 +26,10 @@ internal class GeneratedSources(val testSourcesDir: File, val sharedSourcesDir:
|
|||||||
* [sharedBinariesDir] - The directory with compiled shared modules (klibs).
|
* [sharedBinariesDir] - The directory with compiled shared modules (klibs).
|
||||||
* [givenBinariesDir] - The directory with the given (external) modules (klibs).
|
* [givenBinariesDir] - The directory with the given (external) modules (klibs).
|
||||||
*/
|
*/
|
||||||
internal class Binaries(val testBinariesDir: File, val sharedBinariesDir: File, val givenBinariesDir: File)
|
internal class Binaries(val testBinariesDir: File, lazySharedBinariesDir: () -> File, lazyGivenBinariesDir: () -> File) {
|
||||||
|
val sharedBinariesDir: File by lazy { lazySharedBinariesDir() }
|
||||||
|
val givenBinariesDir: File by lazy { lazyGivenBinariesDir() }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [TestConfiguration] of the current test class and the [Annotation] with specific parameters.
|
* The [TestConfiguration] of the current test class and the [Annotation] with specific parameters.
|
||||||
|
|||||||
Reference in New Issue
Block a user