Base classes for tests put into order:

* KotlinTestWithEnvironmentManagement — methods for creating envirnoments tied up to test root disposable (automatically disposed on teadDown())
* KotlinTestWithEnvironment — a test with one environment (created by an abstract method)

Also, utilities for laz yresolve tests moved to LazyResolveTestUtil
This commit is contained in:
Andrey Breslav
2012-07-11 12:51:58 +04:00
parent 4f5aa9d0fe
commit 8d6fd3a18b
10 changed files with 107 additions and 121 deletions
@@ -16,49 +16,25 @@
package org.jetbrains.jet;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import junit.framework.TestCase;
import com.intellij.testFramework.UsefulTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
/**
* @author abreslav
*/
public abstract class KotlinTestWithEnvironmentManagement extends TestCase {
public abstract class KotlinTestWithEnvironmentManagement extends UsefulTestCase {
static {
System.setProperty("java.awt.headless", "true");
}
private final Disposable rootDisposable = new Disposable() {
@Override
public void dispose() {
}
};
public class JetCoreEnvironmentWithDisposable {
public final JetCoreEnvironment jetCoreEnvironment;
public final Project project;
public JetCoreEnvironmentWithDisposable(@NotNull ConfigurationKind configurationKind) {
this(configurationKind, true);
}
public JetCoreEnvironmentWithDisposable(@NotNull ConfigurationKind configurationKind, boolean mockJdk) {
this.jetCoreEnvironment = new JetCoreEnvironment(rootDisposable,
CompileCompilerDependenciesTest.compilerConfigurationForTests(configurationKind, mockJdk)
);
this.project = jetCoreEnvironment.getProject();
}
protected JetCoreEnvironment createEnvironmentWithMockJdk(@NotNull ConfigurationKind configurationKind) {
return createEnvironmentWithJdk(configurationKind, true);
}
@Override
public void tearDown() throws Exception {
Disposer.dispose(rootDisposable);
super.tearDown();
protected JetCoreEnvironment createEnvironmentWithJdk(@NotNull ConfigurationKind configurationKind, boolean mockJdk) {
return new JetCoreEnvironment(getTestRootDisposable(),
CompileCompilerDependenciesTest.compilerConfigurationForTests(configurationKind, mockJdk)
);
}
}