Minor, inline one overload of CodegenTestUtil.compileJava
This commit is contained in:
@@ -48,7 +48,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.CodegenTestUtil.compileJava;
|
||||
import static org.jetbrains.kotlin.test.KotlinTestUtils.compilerConfigurationForTests;
|
||||
import static org.jetbrains.kotlin.test.KotlinTestUtils.getAnnotationsJar;
|
||||
|
||||
@@ -112,8 +111,9 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
OutputUtilsKt.writeAllTo(classFileFactory, kotlinOut);
|
||||
|
||||
if (javaSourceDir != null) {
|
||||
File output =
|
||||
compileJava(findJavaSourcesInDirectory(javaSourceDir), Collections.singletonList(kotlinOut.getPath()), javacOptions);
|
||||
File output = CodegenTestUtil.compileJava(
|
||||
findJavaSourcesInDirectory(javaSourceDir), Collections.singletonList(kotlinOut.getPath()), javacOptions
|
||||
);
|
||||
// Add javac output to classpath so that the created class loader can find generated Java classes
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, output);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -105,11 +104,6 @@ public class CodegenTestUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File compileJava(@NotNull String filename, @NotNull String... additionalClasspath) {
|
||||
return compileJava(Collections.singletonList(filename), Arrays.asList(additionalClasspath), Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File compileJava(
|
||||
@NotNull List<String> fileNames,
|
||||
|
||||
@@ -38,8 +38,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.CodegenTestUtil.compileJava;
|
||||
import java.util.Collections;
|
||||
|
||||
public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
@NotNull
|
||||
@@ -62,10 +61,18 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
loadFileByFullPath(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + fileName);
|
||||
}
|
||||
|
||||
private void doTestCallAssertions(boolean disableCallAssertions) throws Exception {
|
||||
File javaClassesTempDirectory = compileJava(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/A.java");
|
||||
@NotNull
|
||||
private File compileJava0(@NotNull String fileName) {
|
||||
return CodegenTestUtil.compileJava(
|
||||
Collections.singletonList(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + fileName),
|
||||
Collections.<String>emptyList(),
|
||||
Collections.<String>emptyList()
|
||||
);
|
||||
}
|
||||
|
||||
setUpEnvironment(disableCallAssertions, true, javaClassesTempDirectory);
|
||||
private void doTestCallAssertions(boolean disableCallAssertions) throws Exception {
|
||||
File javaOut = compileJava0("A.java");
|
||||
setUpEnvironment(disableCallAssertions, true, javaOut);
|
||||
|
||||
loadSource("AssertionChecker.kt");
|
||||
generateFunction("checkAssertions").invoke(null, !disableCallAssertions);
|
||||
@@ -101,10 +108,8 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testGenerateParamAssertions() throws Exception {
|
||||
File javaClassesTempDirectory =
|
||||
compileJava(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/doGenerateParamAssertions.java");
|
||||
|
||||
setUpEnvironment(true, false, javaClassesTempDirectory);
|
||||
File javaOut = compileJava0("doGenerateParamAssertions.java");
|
||||
setUpEnvironment(true, false, javaOut);
|
||||
|
||||
loadSource("doGenerateParamAssertions.kt");
|
||||
generateFunction().invoke(null);
|
||||
@@ -137,9 +142,8 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testJavaMultipleSubstitutions() {
|
||||
File javaClassesTempDirectory =
|
||||
compileJava(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/javaMultipleSubstitutions.java");
|
||||
setUpEnvironment(false, false, javaClassesTempDirectory);
|
||||
File javaOut = compileJava0("javaMultipleSubstitutions.java");
|
||||
setUpEnvironment(false, false, javaOut);
|
||||
|
||||
loadSource("javaMultipleSubstitutions.kt");
|
||||
String text = generateToText();
|
||||
|
||||
@@ -33,12 +33,14 @@ import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.CodegenTestUtil.compileJava;
|
||||
import java.util.Collections;
|
||||
|
||||
public class OuterClassGenTest extends CodegenTestCase {
|
||||
|
||||
private static final String TEST_FOLDER = "outerClassInfo";
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getPrefix() {
|
||||
return "outerClassInfo";
|
||||
}
|
||||
|
||||
public void testClass() throws Exception {
|
||||
doTest("foo.Foo", "outerClassInfo");
|
||||
@@ -152,10 +154,13 @@ public class OuterClassGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
private void doTest(@NotNull String classFqName, @NotNull String javaClassName, @NotNull String testDataFile) throws Exception {
|
||||
File javaClassesTempDirectory = compileJava(
|
||||
KotlinTestUtils.getTestDataPathBase() + "/codegen/" + TEST_FOLDER + "/" + testDataFile + ".java");
|
||||
File javaOut = CodegenTestUtil.compileJava(
|
||||
Collections.singletonList(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + testDataFile + ".java"),
|
||||
Collections.<String>emptyList(),
|
||||
Collections.<String>emptyList()
|
||||
);
|
||||
|
||||
UrlClassLoader javaClassLoader = UrlClassLoader.build().urls(javaClassesTempDirectory.toURI().toURL()).get();
|
||||
UrlClassLoader javaClassLoader = UrlClassLoader.build().urls(javaOut.toURI().toURL()).get();
|
||||
|
||||
String javaClassPath = javaClassName.replace('.', File.separatorChar) + ".class";
|
||||
InputStream javaClassStream = javaClassLoader.getResourceAsStream(javaClassPath);
|
||||
@@ -188,7 +193,7 @@ public class OuterClassGenTest extends CodegenTestCase {
|
||||
|
||||
@NotNull
|
||||
private ClassReader getKotlinClassReader(@Language("RegExp") @NotNull String internalNameRegexp, @NotNull String testDataFile) {
|
||||
loadFile(TEST_FOLDER + "/" + testDataFile + ".kt");
|
||||
loadFile(getPrefix() + "/" + testDataFile + ".kt");
|
||||
OutputFileCollection outputFiles = generateClassesInFile();
|
||||
for (OutputFile file : outputFiles.asList()) {
|
||||
if (file.getRelativePath().matches(internalNameRegexp + "\\.class")) {
|
||||
|
||||
Reference in New Issue
Block a user