Android module: add test files which depend on junit.jar
This commit is contained in:
+19
-1
@@ -21,11 +21,14 @@ import com.intellij.openapi.util.io.FileUtil;
|
|||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.testFramework.UsefulTestCase;
|
import com.intellij.testFramework.UsefulTestCase;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
||||||
import org.jetbrains.jet.ConfigurationKind;
|
import org.jetbrains.jet.ConfigurationKind;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
|
import org.jetbrains.jet.TestJdkKind;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.codegen.*;
|
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||||
|
import org.jetbrains.jet.codegen.GenerationUtils;
|
||||||
import org.jetbrains.jet.compiler.PathManager;
|
import org.jetbrains.jet.compiler.PathManager;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||||
@@ -53,6 +56,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
|
|
||||||
private JetCoreEnvironment environmentWithMockJdk = JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, ConfigurationKind.JDK_ONLY);
|
private JetCoreEnvironment environmentWithMockJdk = JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, ConfigurationKind.JDK_ONLY);
|
||||||
private JetCoreEnvironment environmentWithFullJdk = JetTestUtils.createEnvironmentWithFullJdk(myTestRootDisposable);
|
private JetCoreEnvironment environmentWithFullJdk = JetTestUtils.createEnvironmentWithFullJdk(myTestRootDisposable);
|
||||||
|
private JetCoreEnvironment environmentWithFullJdkAndJUnit;
|
||||||
|
|
||||||
private final Pattern packagePattern = Pattern.compile("package (.*)");
|
private final Pattern packagePattern = Pattern.compile("package (.*)");
|
||||||
|
|
||||||
@@ -64,6 +68,16 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
|
|
||||||
private CodegenTestsOnAndroidGenerator(PathManager pathManager) {
|
private CodegenTestsOnAndroidGenerator(PathManager pathManager) {
|
||||||
this.pathManager = pathManager;
|
this.pathManager = pathManager;
|
||||||
|
|
||||||
|
File junitJar = new File("libraries/lib/junit-4.9.jar");
|
||||||
|
|
||||||
|
if (!junitJar.exists()) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
environmentWithFullJdkAndJUnit = new JetCoreEnvironment(myTestRootDisposable, CompileCompilerDependenciesTest.compilerConfigurationForTests(
|
||||||
|
ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar(), junitJar));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateOutputFiles() throws Throwable {
|
private void generateOutputFiles() throws Throwable {
|
||||||
@@ -120,6 +134,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
Assert.assertNotNull("Folder with testData is empty: " + dir.getAbsolutePath(), files);
|
Assert.assertNotNull("Folder with testData is empty: " + dir.getAbsolutePath(), files);
|
||||||
Set<String> excludedFiles = SpecialFiles.getExcludedFiles();
|
Set<String> excludedFiles = SpecialFiles.getExcludedFiles();
|
||||||
Set<String> filesCompiledWithoutStdLib = SpecialFiles.getFilesCompiledWithoutStdLib();
|
Set<String> filesCompiledWithoutStdLib = SpecialFiles.getFilesCompiledWithoutStdLib();
|
||||||
|
Set<String> filesCompiledWithJUnit = SpecialFiles.getFilesCompiledWithJUnit();
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (excludedFiles.contains(file.getName())) {
|
if (excludedFiles.contains(file.getName())) {
|
||||||
continue;
|
continue;
|
||||||
@@ -138,6 +153,9 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
if (filesCompiledWithoutStdLib.contains(file.getName())) {
|
if (filesCompiledWithoutStdLib.contains(file.getName())) {
|
||||||
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithMockJdk);
|
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithMockJdk);
|
||||||
}
|
}
|
||||||
|
else if (filesCompiledWithJUnit.contains(file.getName())) {
|
||||||
|
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithFullJdkAndJUnit);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithFullJdk);
|
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithFullJdk);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,16 @@ import java.util.Set;
|
|||||||
public class SpecialFiles {
|
public class SpecialFiles {
|
||||||
private static final Set<String> excludedFiles = Sets.newHashSet();
|
private static final Set<String> excludedFiles = Sets.newHashSet();
|
||||||
private static final Set<String> filesCompiledWithoutStdLib = Sets.newHashSet();
|
private static final Set<String> filesCompiledWithoutStdLib = Sets.newHashSet();
|
||||||
|
private static final Set<String> filesCompiledWithJUnit = Sets.newHashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
fillExcludedFiles();
|
fillExcludedFiles();
|
||||||
fillFilesCompiledWithoutStdLib();
|
fillFilesCompiledWithoutStdLib();
|
||||||
|
fillFilesCompiledWithJUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<String> getFilesCompiledWithJUnit() {
|
||||||
|
return filesCompiledWithJUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getExcludedFiles() {
|
public static Set<String> getExcludedFiles() {
|
||||||
@@ -43,6 +49,10 @@ public class SpecialFiles {
|
|||||||
public static Set<String> getFilesCompiledWithoutStdLib() {
|
public static Set<String> getFilesCompiledWithoutStdLib() {
|
||||||
return filesCompiledWithoutStdLib;
|
return filesCompiledWithoutStdLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void fillFilesCompiledWithJUnit() {
|
||||||
|
filesCompiledWithJUnit.add("kt2334.kt");
|
||||||
|
}
|
||||||
|
|
||||||
private static void fillFilesCompiledWithoutStdLib() {
|
private static void fillFilesCompiledWithoutStdLib() {
|
||||||
filesCompiledWithoutStdLib.add("kt1953_class.kt"); // Exception in code
|
filesCompiledWithoutStdLib.add("kt1953_class.kt"); // Exception in code
|
||||||
@@ -90,7 +100,7 @@ public class SpecialFiles {
|
|||||||
|
|
||||||
excludedFiles.add("kt1199.kt"); // Bug KT-2202
|
excludedFiles.add("kt1199.kt"); // Bug KT-2202
|
||||||
excludedFiles.add("kt344.jet"); // Bug KT-2251
|
excludedFiles.add("kt344.jet"); // Bug KT-2251
|
||||||
excludedFiles.add("kt529.kt"); // Bug
|
excludedFiles.add("kt529.kt"); // Bug
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpecialFiles() {
|
private SpecialFiles() {
|
||||||
|
|||||||
Reference in New Issue
Block a user