3
3
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4
4
*/
5
5
6
- import com.sun.management.OperatingSystemMXBean
7
6
import org.gradle.api.Project
8
- import org.gradle.api.file.Directory
9
7
import org.gradle.api.file.FileCollection
10
8
import org.gradle.api.file.FileSystemOperations
11
9
import org.gradle.api.file.RegularFileProperty
12
10
import org.gradle.api.internal.tasks.testing.filter.DefaultTestFilter
13
11
import org.gradle.api.model.ObjectFactory
14
- import org.gradle.api.provider.Provider
15
- import org.gradle.api.tasks.ClasspathNormalizer
16
- import org.gradle.api.tasks.InputFile
17
- import org.gradle.api.tasks.PathSensitive
18
- import org.gradle.api.tasks.PathSensitivity
19
- import org.gradle.api.tasks.TaskProvider
12
+ import org.gradle.api.tasks.*
20
13
import org.gradle.api.tasks.testing.Test
21
14
import org.gradle.kotlin.dsl.dependencies
22
15
import org.gradle.kotlin.dsl.newInstance
@@ -27,19 +20,17 @@ import org.gradle.process.CommandLineArgumentProvider
27
20
import java.io.File
28
21
import java.lang.Character.isLowerCase
29
22
import java.lang.Character.isUpperCase
30
- import java.lang.management.ManagementFactory
31
23
import java.nio.file.Files
32
24
import java.nio.file.Path
33
25
import javax.inject.Inject
34
- import kotlin.collections.forEach
35
26
36
27
37
28
// Mixing JUnit4 and Junit5 in one module proved to be problematic, consider using separate modules instead
38
29
enum class JUnitMode {
39
30
JUnit4 , JUnit5
40
31
}
41
32
42
- abstract class MuteWithDatabaseArgumentProvider @Inject constructor(objects : ObjectFactory ) : CommandLineArgumentProvider {
33
+ private abstract class MuteWithDatabaseArgumentProvider @Inject constructor(objects : ObjectFactory ) : CommandLineArgumentProvider {
43
34
@get:InputFile
44
35
@get:PathSensitive(PathSensitivity .NONE )
45
36
val mutesFile: RegularFileProperty = objects.fileProperty()
@@ -48,7 +39,7 @@ abstract class MuteWithDatabaseArgumentProvider @Inject constructor(objects: Obj
48
39
listOf (" -Dorg.jetbrains.kotlin.test.mutes.file=${mutesFile.get().asFile.canonicalPath} " )
49
40
}
50
41
51
- fun Test.muteWithDatabase () {
42
+ private fun Test.muteWithDatabase () {
52
43
jvmArgumentProviders.add(
53
44
project.objects.newInstance<MuteWithDatabaseArgumentProvider >().apply {
54
45
mutesFile.fileValue(File (project.rootDir, " tests/mute-common.csv" ))
@@ -62,7 +53,7 @@ fun Test.muteWithDatabase() {
62
53
* Workaround for TW-92736
63
54
* TC parallelTests.excludesFile may contain invalid entries leading to skipping large groups of tests.
64
55
*/
65
- fun Test.cleanupInvalidExcludePatternsForTCParallelTests (excludesFilePath : String ) {
56
+ private fun Test.cleanupInvalidExcludePatternsForTCParallelTests (excludesFilePath : String ) {
66
57
val candidateTestClassNames = mutableSetOf<String >()
67
58
candidateClassFiles.visit {
68
59
if (! isDirectory && name.endsWith(" .class" )) {
@@ -88,7 +79,7 @@ fun Test.cleanupInvalidExcludePatternsForTCParallelTests(excludesFilePath: Strin
88
79
* @param parallel is redundant if @param jUnit5Enabled is true, because
89
80
* JUnit5 supports parallel test execution by itself, without gradle help
90
81
*/
91
- fun Project.projectTest (
82
+ internal fun Project.createGeneralTestTask (
92
83
taskName : String = "test",
93
84
parallel : Boolean = false,
94
85
jUnitMode : JUnitMode ,
@@ -292,18 +283,9 @@ fun Project.projectTest(
292
283
}.apply { configure(body) }
293
284
}
294
285
295
- val defaultMaxMemoryPerTestWorkerMb = 1600
296
- val reservedMemoryMb = 9000 // system processes, gradle daemon, kotlin daemon, etc ...
286
+ private val defaultMaxMemoryPerTestWorkerMb = 1600
297
287
298
- val totalMaxMemoryForTestsMb: Int
299
- get() {
300
- val mxbean = ManagementFactory .getOperatingSystemMXBean() as OperatingSystemMXBean
301
- return (mxbean.totalPhysicalMemorySize / 1048576 - reservedMemoryMb).toInt()
302
- }
303
-
304
- val Test .commandLineIncludePatterns: Set <String >
288
+ private val Test .commandLineIncludePatterns: Set <String >
305
289
get() = (filter as ? DefaultTestFilter )?.commandLineIncludePatterns.orEmpty()
306
290
307
291
private inline fun String.isFirstChar (f : (Char ) -> Boolean ) = isNotEmpty() && f(first())
308
-
309
- fun Project.ideaHomePathForTests (): Provider <Directory > = rootProject.layout.buildDirectory.dir(" ideaHomeForTests" )
0 commit comments