mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Fixed EA-83158, show suites without run configuration
This commit is contained in:
@@ -29,49 +29,57 @@ class RecentTestsData {
|
||||
|
||||
private val runConfigurationSuites = hashMapOf<String, RunConfigurationEntry>()
|
||||
|
||||
private var unmatchedRunConfigurationTests: MutableList<SingleTestEntry> = arrayListOf<SingleTestEntry>()
|
||||
private var unmatchedRunConfigurationTests = arrayListOf<SingleTestEntry>()
|
||||
|
||||
private val urlSuites = mutableListOf<SuiteEntry>()
|
||||
private var unmatchedUrlTests = mutableListOf<SingleTestEntry>()
|
||||
|
||||
fun addUrlSuite(url: String, magnitude: Magnitude, runDate: Date) {
|
||||
|
||||
fun addSuite(url: String, magnitude: Magnitude, runDate: Date, runConfiguration: RunnerAndConfigurationSettings?) {
|
||||
val suite = SuiteEntry(url, magnitude, runDate)
|
||||
if (runConfiguration != null) {
|
||||
addRunConfigurationSuite(suite, runConfiguration)
|
||||
}
|
||||
else {
|
||||
addUrlSuite(suite)
|
||||
}
|
||||
}
|
||||
|
||||
unmatchedUrlTests.filter { suite.isMyTest(it) }.forEach { suite.addTest(it) }
|
||||
unmatchedUrlTests.filterTo(arrayListOf(), { !suite.isMyTest(it) })
|
||||
fun addTest(url: String, magnitude: Magnitude, runDate: Date, runConfiguration: RunnerAndConfigurationSettings?) {
|
||||
val test = SingleTestEntry(url, magnitude, runDate)
|
||||
if (runConfiguration != null) {
|
||||
addRunConfigurationTest(test, runConfiguration)
|
||||
}
|
||||
else {
|
||||
addUrlTest(test)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUrlSuite(suite: SuiteEntry) {
|
||||
val suiteTests = unmatchedUrlTests.filter { suite.isMyTest(it) }
|
||||
suiteTests.forEach { suite.addTest(it) }
|
||||
|
||||
unmatchedUrlTests = unmatchedUrlTests.filterTo(arrayListOf(), { !suite.isMyTest(it) })
|
||||
|
||||
urlSuites.add(suite)
|
||||
}
|
||||
|
||||
fun addRunConfigurationSuite(url: String,
|
||||
magnitude: Magnitude,
|
||||
runDate: Date,
|
||||
runConfiguration: RunnerAndConfigurationSettings)
|
||||
{
|
||||
|
||||
val suite = SuiteEntry(url, magnitude, runDate)
|
||||
|
||||
unmatchedRunConfigurationTests.filter { suite.isMyTest(it) }.forEach { suite.addTest(it) }
|
||||
private fun addRunConfigurationSuite(suite: SuiteEntry, config: RunnerAndConfigurationSettings) {
|
||||
val suiteTests = unmatchedRunConfigurationTests.filter { suite.isMyTest(it) }
|
||||
suiteTests.forEach { suite.addTest(it) }
|
||||
|
||||
unmatchedRunConfigurationTests = unmatchedRunConfigurationTests.filterTo(arrayListOf(), { !suite.isMyTest(it) })
|
||||
|
||||
val configurationId = runConfiguration.uniqueID
|
||||
val suitePack = runConfigurationSuites[configurationId]
|
||||
if (suitePack != null) {
|
||||
suitePack.addSuite(suite)
|
||||
return
|
||||
}
|
||||
|
||||
runConfigurationSuites[configurationId] = RunConfigurationEntry(runConfiguration, suite)
|
||||
val id = config.uniqueID
|
||||
runConfigurationSuites[id]?.addSuite(suite) ?: runConfigurationSuites.put(id, RunConfigurationEntry(config, suite))
|
||||
}
|
||||
|
||||
fun addUrlTest(url: String, magnitude: Magnitude, runDate: Date) {
|
||||
val test = SingleTestEntry(url, magnitude, runDate)
|
||||
findUrlSuite(url)?.addTest(test) ?: unmatchedUrlTests.add(test)
|
||||
private fun addUrlTest(test: SingleTestEntry) {
|
||||
findUrlSuite(test.url)?.addTest(test) ?: unmatchedUrlTests.add(test)
|
||||
}
|
||||
|
||||
fun addRunConfigurationTest(url: String, magnitude: Magnitude, runDate: Date, runConfiguration: RunnerAndConfigurationSettings) {
|
||||
val test = SingleTestEntry(url, magnitude, runDate)
|
||||
findRunConfigurationTest(url, runConfiguration)?.addTest(test) ?: unmatchedRunConfigurationTests.add(test)
|
||||
private fun addRunConfigurationTest(test: SingleTestEntry, runConfiguration: RunnerAndConfigurationSettings) {
|
||||
findRunConfigurationSuite(test.url, runConfiguration)?.addTest(test) ?: unmatchedRunConfigurationTests.add(test)
|
||||
}
|
||||
|
||||
private fun findUrlSuite(url: String) = urlSuites.find {
|
||||
@@ -79,7 +87,7 @@ class RecentTestsData {
|
||||
testName.startsWith(it.suiteName)
|
||||
}
|
||||
|
||||
private fun findRunConfigurationTest(url: String, runConfiguration: RunnerAndConfigurationSettings): SuiteEntry? {
|
||||
private fun findRunConfigurationSuite(url: String, runConfiguration: RunnerAndConfigurationSettings): SuiteEntry? {
|
||||
val pack: RunConfigurationEntry = runConfigurationSuites[runConfiguration.uniqueID] ?: return null
|
||||
val testName = VirtualFileManager.extractPath(url)
|
||||
|
||||
@@ -94,9 +102,15 @@ class RecentTestsData {
|
||||
|
||||
fun getTestsToShow(): List<RecentTestsPopupEntry> {
|
||||
assert(unmatchedRunConfigurationTests.isEmpty())
|
||||
|
||||
val packsByDate = runConfigurationSuites.values.sortedByDescending { it.runDate }
|
||||
return packsByDate.fold(listOf(), { list, pack -> list + pack.entriesToShow() })
|
||||
val allEntries: List<RecentTestsPopupEntry> = runConfigurationSuites.values + urlSuites
|
||||
return allEntries
|
||||
.sortedByDescending { it.runDate }
|
||||
.fold(listOf(), { popupList, currentEntry ->
|
||||
when (currentEntry) {
|
||||
is RunConfigurationEntry -> popupList + currentEntry.entriesToShow()
|
||||
else -> popupList + currentEntry
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,20 +99,10 @@ public class RecentTestsListProvider {
|
||||
|
||||
RunnerAndConfigurationSettings runConfiguration = myConfigurationProvider.getConfiguration(record);
|
||||
if (TestLocator.isSuite(url)) {
|
||||
if (runConfiguration != null) {
|
||||
data.addRunConfigurationSuite(url, magnitude, record.date, runConfiguration);
|
||||
}
|
||||
else {
|
||||
data.addUrlSuite(url, magnitude, record.date);
|
||||
}
|
||||
data.addSuite(url, magnitude, record.date, runConfiguration);
|
||||
}
|
||||
else {
|
||||
if (runConfiguration != null) {
|
||||
data.addRunConfigurationTest(url, magnitude, record.date, runConfiguration);
|
||||
}
|
||||
else {
|
||||
data.addUrlTest(url, magnitude, record.date);
|
||||
}
|
||||
data.addTest(url, magnitude, record.date, runConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.mock
|
||||
import java.util.*
|
||||
|
||||
fun String.suite() = "java:suite://$this"
|
||||
fun String.test() = "java:test://$this"
|
||||
|
||||
class RecentTestsStepTest: LightIdeaTestCase() {
|
||||
|
||||
lateinit var data: RecentTestsData
|
||||
@@ -38,16 +41,24 @@ class RecentTestsStepTest: LightIdeaTestCase() {
|
||||
`when`(allTests.name).thenAnswer { "all tests" }
|
||||
now = Date()
|
||||
}
|
||||
|
||||
fun `test show suites without run configuration`() {
|
||||
data.addTest("Test.x".test(), TestStateInfo.Magnitude.PASSED_INDEX, now, null)
|
||||
data.addSuite("Test".suite(), TestStateInfo.Magnitude.PASSED_INDEX, now, null)
|
||||
|
||||
val tests = data.getTestsToShow()
|
||||
assertThat(tests).hasSize(1)
|
||||
}
|
||||
|
||||
fun `test all tests passed`() {
|
||||
data.addRunConfigurationTest("java:test://Test.textXXX", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationSuite("java:suite://Test", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationSuite("java:suite://JavaFormatterSuperDuperTest", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://Test.textYYY", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://Test.textZZZ", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://Test.textQQQ", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://Test.textXXX", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addSuite("java:suite://Test", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addSuite("java:suite://JavaFormatterSuperDuperTest", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://Test.textYYY", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://Test.textZZZ", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://Test.textQQQ", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
|
||||
val tests = data.getTestsToShow()
|
||||
assertThat(tests).hasSize(1)
|
||||
@@ -56,13 +67,13 @@ class RecentTestsStepTest: LightIdeaTestCase() {
|
||||
|
||||
|
||||
fun `test if one failed in run configuration show failed suite`() {
|
||||
data.addRunConfigurationSuite("java:suite://JavaFormatterSuperDuperTest", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addRunConfigurationSuite("java:suite://Test", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addSuite("java:suite://JavaFormatterSuperDuperTest", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addSuite("java:suite://Test", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
|
||||
data.addRunConfigurationTest("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addTest("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
|
||||
data.addRunConfigurationTest("java:test://Test.textXXX", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addTest("java:test://Test.textXXX", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
|
||||
val tests = data.getTestsToShow()
|
||||
|
||||
@@ -73,9 +84,9 @@ class RecentTestsStepTest: LightIdeaTestCase() {
|
||||
|
||||
|
||||
fun `test if configuration with single test show failed test`() {
|
||||
data.addRunConfigurationSuite("java:suite://JavaFormatterSuperDuperTest", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addRunConfigurationTest("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
data.addSuite("java:suite://JavaFormatterSuperDuperTest", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addTest("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt", TestStateInfo.Magnitude.FAILED_INDEX, now, allTests)
|
||||
data.addTest("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", TestStateInfo.Magnitude.PASSED_INDEX, now, allTests)
|
||||
|
||||
val tests = data.getTestsToShow()
|
||||
assertThat(tests).hasSize(2)
|
||||
|
||||
Reference in New Issue
Block a user