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:
@@ -20,6 +20,9 @@ import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinTestWithEnvironment;
|
||||
import org.jetbrains.k2js.config.EcmaVersion;
|
||||
import org.jetbrains.k2js.facade.MainCallParameters;
|
||||
import org.jetbrains.k2js.test.config.TestConfig;
|
||||
@@ -38,7 +41,7 @@ import static org.jetbrains.k2js.test.utils.JsTestUtils.convertFileNameToDotJsFi
|
||||
/**
|
||||
* @author Pavel Talanov
|
||||
*/
|
||||
public abstract class BasicTest extends TestWithEnvironment {
|
||||
public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
|
||||
private static final boolean DELETE_OUT = false;
|
||||
private static final String TEST_FILES = "js/js.translator/testFiles/";
|
||||
@@ -56,6 +59,11 @@ public abstract class BasicTest extends TestWithEnvironment {
|
||||
this.mainDirectory = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JetCoreEnvironment createEnvironment() {
|
||||
return JetCoreEnvironment.createCoreEnvironmentForJVM(getTestRootDisposable(), new CompilerConfiguration());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.k2js.test;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
|
||||
/**
|
||||
* @author Pavel Talanov
|
||||
*/
|
||||
public abstract class TestWithEnvironment extends UsefulTestCase {
|
||||
|
||||
@Nullable
|
||||
protected JetCoreEnvironment myEnvironment;
|
||||
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
assert myEnvironment != null : "Environment should be created beforehand.";
|
||||
return myEnvironment.getProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myEnvironment = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void createEnvironmentWithMockJdkAndIdeaAnnotations() {
|
||||
myEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(getTestRootDisposable(), new CompilerConfiguration());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user