@@ -64,6 +64,20 @@ class RunConfigurationHelper {
64
64
companion object {
65
65
private val logger = KotlinLogging .logger {}
66
66
67
+ private fun RunConfiguration.isPatternBased () = this is JavaTestConfigurationBase && testType == " pattern"
68
+
69
+ // In case we do "generate and run" for many files at once,
70
+ // desired run configuration has to be one of "pattern" typed test configuration that may run many tests at once.
71
+ // Thus, we sort list of all provided configurations to get desired configuration the first.
72
+ private val rcComparator = Comparator <ConfigurationFromContext > { o1, o2 ->
73
+ val p1 = o1.configuration.isPatternBased()
74
+ val p2 = o2.configuration.isPatternBased()
75
+ if (p1 xor p2) {
76
+ return @Comparator if (p1) - 1 else 1
77
+ }
78
+ ConfigurationFromContext .COMPARATOR .compare(o1, o2)
79
+ }
80
+
67
81
fun runTestsWithCoverage (
68
82
model : GenerateTestsModel ,
69
83
testFilesPointers : MutableList <SmartPsiElementPointer <PsiFile >>,
@@ -91,17 +105,9 @@ class RunConfigurationHelper {
91
105
)
92
106
run (IntelliJApiHelper .Target .THREAD_POOL ) {
93
107
val configurations = ApplicationManager .getApplication().runReadAction(Computable {
94
- val list = RunConfigurationProducer .getProducers(model.project)
108
+ return @Computable RunConfigurationProducer .getProducers(model.project)
95
109
.mapNotNull { it.findOrCreateConfigurationFromContext(myConfigurationContext) }
96
- .toMutableList().sortedWith(Comparator <ConfigurationFromContext > { o1, o2 ->
97
- val p1 = o1.configuration.isPatternBased()
98
- val p2 = o2.configuration.isPatternBased()
99
- if (p1 xor p2) {
100
- return @Comparator if (p1) - 1 else 1
101
- }
102
- ConfigurationFromContext .COMPARATOR .compare(o1, o2)
103
- })
104
- return @Computable list
110
+ .toMutableList().sortedWith(rcComparator)
105
111
})
106
112
107
113
val settings = if (configurations.isEmpty()) null else configurations[0 ].configurationSettings
@@ -128,7 +134,5 @@ class RunConfigurationHelper {
128
134
}
129
135
}
130
136
}
131
-
132
- private fun RunConfiguration.isPatternBased () = this is JavaTestConfigurationBase && testType == " pattern"
133
137
}
134
138
}
0 commit comments