use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileEnvironmentTest method testSmokeWithCompilerOutput.
public void testSmokeWithCompilerOutput() throws IOException {
File tempDir = FileUtil.createTempDirectory("compilerTest", "compilerTest");
try {
File out = new File(tempDir, "out");
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
ExitCode exitCode = new K2JVMCompiler().exec(System.out, KotlinTestUtils.getTestDataPathBase() + "/compiler/smoke/Smoke.kt", "-d", out.getAbsolutePath(), "-no-stdlib", "-classpath", stdlib.getAbsolutePath());
Assert.assertEquals(ExitCode.OK, exitCode);
File[] files = out.listFiles();
Arrays.sort(files);
assertEquals(2, files.length);
//META-INF
assertEquals(1, files[0].listFiles().length);
// SmokeKt
assertEquals(1, files[1].listFiles().length);
} finally {
FileUtil.delete(tempDir);
}
}
use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method doTestKotlinLibraryWithWrongMetadataVersion.
private void doTestKotlinLibraryWithWrongMetadataVersion(@NotNull String libraryName, @Nullable final Function2<String, Object, Object> additionalTransformation, @NotNull String... additionalOptions) throws Exception {
final int[] version = new JvmMetadataVersion(42, 0, 0).toArray();
File library = transformJar(compileLibrary(libraryName), new Function2<String, byte[], byte[]>() {
@Override
public byte[] invoke(String name, byte[] bytes) {
return WrongBytecodeVersionTest.Companion.transformMetadataInClassFile(bytes, new Function2<String, Object, Object>() {
@Override
public Object invoke(String name, Object value) {
if (additionalTransformation != null) {
Object result = additionalTransformation.invoke(name, value);
if (result != null)
return result;
}
return JvmAnnotationNames.METADATA_VERSION_FIELD_NAME.equals(name) ? version : null;
}
});
}
});
Pair<String, ExitCode> output = compileKotlin("source.kt", tmpdir, Arrays.asList(additionalOptions), library);
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(output));
}
use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testTypeAliasesAreInvisibleInCompatibilityMode.
public void testTypeAliasesAreInvisibleInCompatibilityMode() {
compileKotlin("typeAliases.kt", tmpdir);
Pair<String, ExitCode> outputMain = compileKotlin("main.kt", tmpdir, Arrays.asList("-language-version", "1.0"), tmpdir);
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(outputMain));
}
use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testInnerClassPackageConflict.
public void testInnerClassPackageConflict() throws Exception {
compileJava("library");
FileUtil.copy(new File(getTestDataDirectory(), "library/test/Foo/x.txt"), new File(tmpdir, "library/test/Foo/x.txt"));
MockLibraryUtil.createJarFile(tmpdir, new File(tmpdir, "library"), null, "library", false);
File jarPath = new File(tmpdir, "library.jar");
Pair<String, ExitCode> output = compileKotlin("source.kt", tmpdir, jarPath);
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(output));
}
Aggregations