Move BuildSessionLoggerTest to :kotlin-gradle-plugin tests

There was a problem that :kotlin-gradle-statistics:test can not be
  properly imported and kotlin stdlib wasn't accessible in it. I didn't
  find a way to fix it in :kotlin-gradle-statistics module, so I just
  moved tests from it to others gradle plugin tests
This commit is contained in:
Dmitriy Novozhilov
2021-07-23 14:19:08 +03:00
committed by teamcityserver
parent a7549be95e
commit d9d2a9cc31
3 changed files with 11 additions and 20 deletions
@@ -1,12 +1,11 @@
/* /*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2021 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. * 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.statistics package org.jetbrains.kotlin.gradle.statistics
import org.jetbrains.kotlin.statistics.BuildSessionLogger.Companion.STATISTICS_FILE_NAME_PATTERN import org.jetbrains.kotlin.statistics.BuildSessionLogger
import org.jetbrains.kotlin.statistics.BuildSessionLogger.Companion.listProfileFiles
import org.jetbrains.kotlin.statistics.fileloggers.MetricsContainer import org.jetbrains.kotlin.statistics.fileloggers.MetricsContainer
import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics
import org.jetbrains.kotlin.statistics.metrics.NumericalMetrics import org.jetbrains.kotlin.statistics.metrics.NumericalMetrics
@@ -59,8 +58,8 @@ class BuildSessionLoggerTest {
rootFolder.listFiles().first().listFiles().forEach { file -> rootFolder.listFiles().first().listFiles().forEach { file ->
assertTrue( assertTrue(
file.name.matches(STATISTICS_FILE_NAME_PATTERN.toRegex()), file.name.matches(BuildSessionLogger.STATISTICS_FILE_NAME_PATTERN.toRegex()),
"Check that file name ${file.name} matches pattern $STATISTICS_FILE_NAME_PATTERN" "Check that file name ${file.name} matches pattern ${BuildSessionLogger.STATISTICS_FILE_NAME_PATTERN}"
) )
} }
} }
@@ -118,18 +117,18 @@ class BuildSessionLoggerTest {
// files not matching the pattern should not be affected // files not matching the pattern should not be affected
assertEquals( assertEquals(
200, 200,
statsFolder.listFiles().filter { !it.name.matches(STATISTICS_FILE_NAME_PATTERN.toRegex()) }.count(), statsFolder.listFiles().filter { !it.name.matches(BuildSessionLogger.STATISTICS_FILE_NAME_PATTERN.toRegex()) }.count(),
"Some files which should not be affected, were removed" "Some files which should not be affected, were removed"
) )
assertEquals( assertEquals(
maxFiles, maxFiles,
statsFolder.listFiles().filter { it.name.matches(STATISTICS_FILE_NAME_PATTERN.toRegex()) }.count(), statsFolder.listFiles().filter { it.name.matches(BuildSessionLogger.STATISTICS_FILE_NAME_PATTERN.toRegex()) }.count(),
"Some files which should not be affected, were removed" "Some files which should not be affected, were removed"
) )
assertEquals( assertEquals(
statsFolder.listFiles().filter { it.name.matches(STATISTICS_FILE_NAME_PATTERN.toRegex()) }.sorted(), statsFolder.listFiles().filter { it.name.matches(BuildSessionLogger.STATISTICS_FILE_NAME_PATTERN.toRegex()) }.sorted(),
listProfileFiles(statsFolder) BuildSessionLogger.listProfileFiles(statsFolder)
) )
} }
@@ -12,15 +12,7 @@ dependencies {
sourceSets { sourceSets {
"main" { projectDefault() } "main" { projectDefault() }
"test" { "test" { projectDefault() }
if (kotlinBuildProperties.isJpsBuildEnabled || kotlinBuildProperties.useFir) {
none()
} else {
none()
// projectDefault()
}
}
} }
projectTest { projectTest {
@@ -24,7 +24,7 @@ class BuildSessionLogger(
companion object { companion object {
const val STATISTICS_FOLDER_NAME = "kotlin-profile" const val STATISTICS_FOLDER_NAME = "kotlin-profile"
internal const val STATISTICS_FILE_NAME_PATTERN = "\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}-\\d{2}-\\d{3}.profile" const val STATISTICS_FILE_NAME_PATTERN = "\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}-\\d{2}-\\d{3}.profile"
private const val DEFAULT_MAX_PROFILE_FILES = 1_000 private const val DEFAULT_MAX_PROFILE_FILES = 1_000
private const val DEFAULT_MAX_PROFILE_FILE_SIZE = 100_000L private const val DEFAULT_MAX_PROFILE_FILE_SIZE = 100_000L