Add tests on Kotlin against compiled Java+Kotlin
The original purpose was to create a test that parameter names are inherited on a K-J-K hierarchy when "K-J" is compiled to bytecode, but that's not possible right now because of KT-4509
This commit is contained in:
committed by
Andrey Breslav
parent
291741754b
commit
888a6c0c9b
@@ -73,6 +73,7 @@ import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.slicedmap.SlicedMap;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.junit.Assert;
|
||||
|
||||
import javax.tools.*;
|
||||
@@ -89,6 +90,7 @@ import static org.jetbrains.jet.ConfigurationKind.ALL;
|
||||
import static org.jetbrains.jet.ConfigurationKind.JDK_AND_ANNOTATIONS;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.CLASSPATH_KEY;
|
||||
import static org.jetbrains.jet.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetAnalyzeExhaust;
|
||||
|
||||
public class JetTestUtils {
|
||||
private static final Pattern KT_FILES = Pattern.compile(".*?.kt");
|
||||
@@ -443,7 +445,28 @@ public class JetTestUtils {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void compileKotlinWithJava(
|
||||
@NotNull List<File> javaFiles,
|
||||
@NotNull List<File> ktFiles,
|
||||
@NotNull File outDir,
|
||||
@NotNull Disposable disposable
|
||||
) throws IOException {
|
||||
if (!ktFiles.isEmpty()) {
|
||||
compileKotlinToDirAndGetAnalyzeExhaust(ktFiles, outDir, disposable, ALL);
|
||||
}
|
||||
else {
|
||||
boolean mkdirs = outDir.mkdirs();
|
||||
assert mkdirs : "Not created: " + outDir;
|
||||
}
|
||||
if (!javaFiles.isEmpty()) {
|
||||
compileJavaFiles(javaFiles, Arrays.asList(
|
||||
"-classpath", outDir.getPath() + File.pathSeparator + ForTestCompileRuntime.runtimeJarForTests(),
|
||||
"-d", outDir.getPath()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user