New test runners: legacy configuration detection improved

* In old version we used to check testType which is never null
This commit is contained in:
Ilya.Kazakevich
2017-02-01 16:23:02 +03:00
parent 57fdfa015a
commit 0c478585cf
@@ -149,7 +149,7 @@ class PyUniversalTestLegacyConfigurationAdapter<in T : PyUniversalTestConfigurat
override fun readExternal(element: Element) {
configManager.legacyConfig.readExternal(element)
containsLegacyInformation = (configManager.legacyConfig.getTestType() != null)
containsLegacyInformation = configManager.loaded
}
@@ -192,6 +192,17 @@ private abstract class LegacyConfigurationManager<
return clazz.findMethodByName(legacyConfig.methodName, true, TypeEvalContext.userInitiated(legacyConfig.project, script))
}
/**
* If one of these fields is not empty -- legacy configuration makes sence
*/
open protected val fieldsToCheckForEmptiness = listOf(legacyConfig.scriptName, legacyConfig.className, legacyConfig.methodName)
/**
* @return true of legacy configuration loaded, false if configuration is pure new
*/
val loaded: Boolean
get() = fieldsToCheckForEmptiness.find { !it.isNullOrBlank() } != null
/**
* Copies config from legacy to new configuration.
* Used by all runners but py.test which has very different settings
@@ -230,6 +241,8 @@ private class LegacyConfigurationManagerPyTest(newConfig: PyUniversalPyTestConfi
*/
private val KEYWORDS_SPLIT_PATTERN = java.util.regex.Pattern.compile("\\s+and\\s+", java.util.regex.Pattern.CASE_INSENSITIVE)
override val fieldsToCheckForEmptiness = super.fieldsToCheckForEmptiness + listOf(legacyConfig.keywords, legacyConfig.testToRun)
override fun copyFromLegacy() {
// Do not call parent since target is always provided as testToRun here
newConfig.additionalArguments = legacyConfig.params