use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method doTestPreReleaseKotlinLibrary.
@SuppressWarnings("deprecation")
private void doTestPreReleaseKotlinLibrary(@NotNull CLICompiler<?> compiler, @NotNull String libraryName, @NotNull File destination, @NotNull File result, @NotNull String... additionalOptions) throws Exception {
try {
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "true");
compileLibrary(compiler, libraryName, destination, Collections.<String>emptyList());
} finally {
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY);
}
Pair<String, ExitCode> output;
try {
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "false");
output = compileKotlin(compiler, "source.kt", tmpdir, Arrays.asList(additionalOptions), result);
} finally {
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY);
}
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 testMissingDependencyJavaConflictingLibraries.
public void testMissingDependencyJavaConflictingLibraries() throws Exception {
File library1 = deletePaths(compileJava("library1"), "test/A.class", "test/A$Inner.class");
File library2 = deletePaths(compileJava("library2"), "test/A.class", "test/A$Inner.class");
Pair<String, ExitCode> output = compileKotlin("source.kt", tmpdir, library1, library2);
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 doTestBrokenJavaLibrary.
private void doTestBrokenJavaLibrary(@NotNull String libraryName, @NotNull String... pathsToDelete) throws Exception {
// This function compiles a Java library, then deletes one class file and attempts to compile a Kotlin source against
// this broken library. The expected result is an error message from the compiler
File library = deletePaths(compileJava(libraryName), pathsToDelete);
Pair<String, ExitCode> output = compileKotlin("source.kt", tmpdir, 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 KotlinCompileMojoBase method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Kotlin Compiler version " + KotlinCompilerVersion.VERSION);
if (!hasKotlinFilesInSources()) {
getLog().warn("No sources found skipping Kotlin compile");
return;
}
A arguments = createCompilerArguments();
CLICompiler<A> compiler = createCompiler();
configureCompilerArguments(arguments, compiler);
printCompilerArgumentsIfDebugEnabled(arguments, compiler);
MavenPluginLogMessageCollector messageCollector = new MavenPluginLogMessageCollector(getLog());
ExitCode exitCode = compiler.exec(messageCollector, Services.EMPTY, arguments);
if (exitCode != ExitCode.OK) {
messageCollector.throwKotlinCompilerException();
}
}
use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class AbstractCliTest method doTest.
private void doTest(@NotNull String fileName, @NotNull CLICompiler<?> compiler, BinaryVersion version) throws Exception {
System.setProperty("java.awt.headless", "true");
Pair<String, ExitCode> outputAndExitCode = executeCompilerGrabOutput(compiler, readArgs(fileName, tmpdir.getPath()));
String actual = getNormalizedCompilerOutput(outputAndExitCode.getFirst(), outputAndExitCode.getSecond(), new File(fileName).getParent(), version);
File outFile = new File(fileName.replaceFirst("\\.args$", ".out"));
KotlinTestUtils.assertEqualsToFile(outFile, actual);
File additionalTestConfig = new File(fileName.replaceFirst("\\.args$", ".test"));
if (additionalTestConfig.exists()) {
doTestAdditionalChecks(additionalTestConfig);
}
}
Aggregations