[Native][tests] Don't track used memory when running in TeamCity

This commit is contained in:
Dmitriy Dolovov
2023-05-11 19:46:50 +02:00
committed by Space Team
parent 6f249ab615
commit 42a8b28337
3 changed files with 15 additions and 2 deletions
+10 -1
View File
@@ -24,7 +24,8 @@ private enum class TestProperty(shortName: String) {
GC_SCHEDULER("gcScheduler"),
CACHE_MODE("cacheMode"),
EXECUTION_TIMEOUT("executionTimeout"),
SANITIZER("sanitizer");
SANITIZER("sanitizer"),
TEAMCITY("teamcity");
val fullName = "kotlin.internal.native.test.$shortName"
}
@@ -55,6 +56,11 @@ private class ComputedTestProperties(private val task: Test) {
ComputedTestProperty.Lazy(property.fullName, defaultLazyValue())
}
// Do not attempt to read the property from Gradle. Instead, set it based on the lambda return value.
fun computePrivate(property: TestProperty, value: () -> String) {
computedProperties += ComputedTestProperty.Normal(property.fullName, value())
}
fun lazyClassPath(builder: MutableList<File>.() -> Unit): Lazy<String?> = lazy(LazyThreadSafetyMode.NONE) {
buildList(builder).takeIf { it.isNotEmpty() }?.joinToString(File.pathSeparator) { it.absolutePath }
}
@@ -167,6 +173,9 @@ fun Project.nativeTest(
compute(CACHE_MODE)
compute(EXECUTION_TIMEOUT)
compute(SANITIZER)
// Pass whether tests are running at TeamCity.
computePrivate(TEAMCITY) { kotlinBuildProperties.isTeamcityBuild.toString() }
}
// Pass the current Gradle task name so test can use it in logging.
@@ -12,7 +12,8 @@ import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail
internal enum class ProcessLevelProperty(shortName: String) {
KOTLIN_NATIVE_HOME("nativeHome"),
COMPILER_CLASSPATH("compilerClasspath");
COMPILER_CLASSPATH("compilerClasspath"),
TEAMCITY("teamcity");
private val propertyName = fullPropertyName(shortName)
@@ -112,6 +112,9 @@ private object NativeTestSupport {
}
private fun ExtensionContext.setUpMemoryTracking() {
if (ProcessLevelProperty.TEAMCITY.readValue().toBoolean())
return // Don't track memory when running at TeamCity. It tracks memory by itself.
TestLogger.initialize() // Initialize special logging (directly to Gradle's console).
val gradleTaskName = EnvironmentVariable.GRADLE_TASK_NAME.readValue()