Do not store test factories in static fields.

``ConfigurationType`` must be unloadable because of "dynamic" EP.

Since ConfigurationFactory stores type as final field, we can't store factories as static fields.

GitOrigin-RevId: 0333eb6632de2f51c5c28651cc595fe895490e4c
This commit is contained in:
Ilya.Kazakevich
2019-11-28 22:35:04 +00:00
committed by intellij-monorepo-bot
parent b31c556606
commit fecfdd52f4
12 changed files with 22 additions and 22 deletions
@@ -45,8 +45,8 @@ class PyNoseTestConfiguration(project: Project, factory: PyNoseTestFactory) :
override fun isFrameworkInstalled(): Boolean = VFSTestFrameworkListener.getInstance().isTestFrameworkInstalled(sdk, PyNames.NOSE_TEST)
}
object PyNoseTestFactory : PyAbstractTestFactory<PyNoseTestConfiguration>() {
class PyNoseTestFactory : PyAbstractTestFactory<PyNoseTestConfiguration>() {
override fun createTemplateConfiguration(project: Project) = PyNoseTestConfiguration(project, this)
override fun getName(): String = PyTestFrameworkService.getSdkReadableNameByFramework(PyNames.NOSE_TEST)
}
}
@@ -81,7 +81,7 @@ class PyTestConfiguration(project: Project, factory: PyTestFactory)
}
}
object PyTestFactory : PyAbstractTestFactory<PyTestConfiguration>() {
class PyTestFactory : PyAbstractTestFactory<PyTestConfiguration>() {
override fun createTemplateConfiguration(project: Project): PyTestConfiguration = PyTestConfiguration(project, this)
override fun getName(): String = PyTestFrameworkService.getSdkReadableNameByFramework(PyNames.PY_TEST)
@@ -66,11 +66,11 @@ import java.util.regex.Matcher
/**
* New configuration factories
*/
internal val pythonFactories: Array<PythonConfigurationFactoryBase> = arrayOf(
PyUnitTestFactory,
PyTestFactory,
PyNoseTestFactory,
PyTrialTestFactory)
internal val pythonFactories get() = arrayOf<PythonConfigurationFactoryBase>(
PyUnitTestFactory(),
PyTestFactory(),
PyNoseTestFactory(),
PyTrialTestFactory())
/**
* Accepts text that may be wrapped in TC message. Unwarps it and removes TC escape code.
@@ -53,8 +53,8 @@ class PyTrialTestConfiguration(project: Project, factory: PyTrialTestFactory)
}
object PyTrialTestFactory : PyAbstractTestFactory<PyTrialTestConfiguration>() {
class PyTrialTestFactory : PyAbstractTestFactory<PyTrialTestConfiguration>() {
override fun createTemplateConfiguration(project: Project): PyTrialTestConfiguration = PyTrialTestConfiguration(project, this)
override fun getName(): String = PyTestFrameworkService.getSdkReadableNameByFramework(PyNames.TRIAL_TEST)
}
}
@@ -102,8 +102,8 @@ class PyUnitTestConfiguration(project: Project, factory: PyUnitTestFactory) :
override fun shouldSeparateTargetPath() = false
}
object PyUnitTestFactory : PyAbstractTestFactory<PyUnitTestConfiguration>() {
class PyUnitTestFactory : PyAbstractTestFactory<PyUnitTestConfiguration>() {
override fun createTemplateConfiguration(project: Project): PyUnitTestConfiguration = PyUnitTestConfiguration(project, this)
override fun getName(): String = PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME
}
}
@@ -166,7 +166,7 @@ public final class PythonNoseTestingTest extends PyEnvTestCase {
@NotNull
@Override
protected PyNoseTestFactory createFactory() {
return PyNoseTestFactory.INSTANCE;
return new PyNoseTestFactory();
}
});
}
@@ -120,7 +120,7 @@ public final class PythonPyTestingTest extends PyEnvTestCase {
final CharBuffer data = Charset.defaultCharset().decode(ByteBuffer.wrap(file.contentsToByteArray()));
final Element element = builder.build(new StringReader(data.toString())).getRootElement();
final PyTestConfiguration configuration = new PyTestConfiguration(myFixture.getProject(), PyTestFactory.INSTANCE);
final PyTestConfiguration configuration = new PyTestConfiguration(myFixture.getProject(), new PyTestFactory());
configuration.readExternal(element);
return configuration;
}
@@ -484,7 +484,7 @@ public final class PythonPyTestingTest extends PyEnvTestCase {
@NotNull
@Override
protected PyAbstractTestFactory<PyTestConfiguration> createFactory() {
return PyTestFactory.INSTANCE;
return new PyTestFactory();
}
@Override
@@ -600,7 +600,7 @@ public final class PythonPyTestingTest extends PyEnvTestCase {
@NotNull
@Override
protected PyTestFactory createFactory() {
return PyTestFactory.INSTANCE;
return new PyTestFactory();
}
});
}
@@ -50,7 +50,7 @@ internal class PythonTrialTest : PythonUnitTestingLikeTest<PyTrialTestProcessRun
class PyTrialTestProcessRunner(scriptName: String,
timesToRerunFailedTests: Int) : PyScriptTestProcessRunner<PyTrialTestConfiguration>(
PyTrialTestFactory, PyTrialTestConfiguration::class.java, scriptName, timesToRerunFailedTests) {
PyTrialTestFactory(), PyTrialTestConfiguration::class.java, scriptName, timesToRerunFailedTests) {
override fun configurationCreatedAndWillLaunch(configuration: PyTrialTestConfiguration) {
super.configurationCreatedAndWillLaunch(configuration)
configuration.additionalArguments = "--temp-directory=" + File(createTempDir(), "trial").path
@@ -237,7 +237,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@NotNull
@Override
protected PyUnitTestFactory createFactory() {
return PyUnitTestFactory.INSTANCE;
return new PyUnitTestFactory();
}
@Override
@@ -870,7 +870,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
@Override
public void runTestOn(@NotNull final String sdkHome, @Nullable Sdk existingSdk) throws InvalidSdkException {
// Set default working directory to some random location before actual exection
final PyUnitTestConfiguration templateConfiguration = getTemplateConfiguration(PyUnitTestFactory.INSTANCE);
final PyUnitTestConfiguration templateConfiguration = getTemplateConfiguration(new PyUnitTestFactory());
templateConfiguration.setWorkingDirectory(SOME_RANDOM_DIR);
super.runTestOn(sdkHome, existingSdk);
templateConfiguration.setWorkingDirectory("");
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
*/
public class PyNoseTestProcessRunner extends PyScriptTestProcessRunner<PyNoseTestConfiguration> {
public PyNoseTestProcessRunner(@NotNull final String scriptName, final int timesToRerunFailedTests) {
super(PyNoseTestFactory.INSTANCE,
super(new PyNoseTestFactory(),
PyNoseTestConfiguration.class, scriptName, timesToRerunFailedTests);
}
}
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
*/
public class PyTestTestProcessRunner extends PyScriptTestProcessRunner<PyTestConfiguration> {
public PyTestTestProcessRunner(@NotNull final String scriptName, final int timesToRerunFailedTests) {
super(PyTestFactory.INSTANCE,
super(new PyTestFactory(),
PyTestConfiguration.class, scriptName, timesToRerunFailedTests);
}
}
@@ -38,7 +38,7 @@ public class PyUnitTestProcessRunner extends PyScriptTestProcessRunner<PyUnitTes
public static final String TEST_PATTERN_PREFIX = "pattern:";
public PyUnitTestProcessRunner(@NotNull final String scriptName, final int timesToRerunFailedTests) {
super(PyUnitTestFactory.INSTANCE,
super(new PyUnitTestFactory(),
PyUnitTestConfiguration.class, scriptName, timesToRerunFailedTests);
}