use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testWrongInlineTarget.
public void testWrongInlineTarget() throws Exception {
File library = compileLibrary("library", Arrays.asList("-jvm-target", "1.8"));
Pair<String, ExitCode> outputMain = compileKotlin("source.kt", tmpdir, library);
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 testMissingDependencyConflictingLibraries.
public void testMissingDependencyConflictingLibraries() throws Exception {
File library1 = copyJarFileWithoutEntry(compileLibrary("library1"), "a/A.class", "a/A$Inner.class", "a/AA.class", "a/AA$Inner.class");
File library2 = copyJarFileWithoutEntry(compileLibrary("library2"), "a/A.class", "a/A$Inner.class", "a/AA.class", "a/AA$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 AbstractCliTest method executeCompilerGrabOutput.
@NotNull
public static Pair<String, ExitCode> executeCompilerGrabOutput(@NotNull CLICompiler<?> compiler, @NotNull List<String> args) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
PrintStream origErr = System.err;
try {
System.setErr(new PrintStream(bytes));
ExitCode exitCode = CLICompiler.doMainNoExit(compiler, ArrayUtil.toStringArray(args));
return new Pair<String, ExitCode>(bytes.toString("utf-8"), exitCode);
} catch (Exception e) {
throw ExceptionUtilsKt.rethrow(e);
} finally {
System.setErr(origErr);
}
}
use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileMavenGeneratedJSLibrary method generateJavaScriptFiles.
private void generateJavaScriptFiles(@NotNull Iterable<EcmaVersion> ecmaVersions, @NotNull String sourceDir, @NotNull String... stdLibFiles) throws Exception {
List<String> files = Lists.newArrayList();
// now lets add all the files from the definitions and library
//addAllSourceFiles(files, generatedJsDefinitionsDir);
addAllSourceFiles(files, generatedJsLibraryDir);
File stdlibDir = new File(sourceDir);
assertTrue("Cannot find stdlib test source: " + stdlibDir, stdlibDir.exists());
for (String file : stdLibFiles) {
files.add(new File(stdlibDir, file).getPath());
}
// now lets try invoke the compiler
for (EcmaVersion version : ecmaVersions) {
String outputFile = getOutputFilePath(getTestName(false) + ".compiler.kt", version);
System.out.println("Compiling with version: " + version + " to: " + outputFile);
List<String> args = new ArrayList<String>(Arrays.asList("-output", outputFile, "-libraries", generatedJsDefinitionsDir, "-verbose"));
args.addAll(files);
ExitCode answer = new K2JSCompiler().exec(System.out, ArrayUtil.toStringArray(args));
assertEquals("Compile failed", ExitCode.OK, answer);
}
}
use of org.jetbrains.kotlin.cli.common.ExitCode in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testProhibitNestedClassesByDollarName.
public void testProhibitNestedClassesByDollarName() throws Exception {
File library = compileLibrary("library");
KotlinTestUtils.compileJavaFiles(Collections.singletonList(new File(getTestDataDirectory() + "/library/test/JavaOuter.java")), Arrays.asList("-d", tmpdir.getPath()));
Pair<String, ExitCode> outputMain = compileKotlin("main.kt", tmpdir, tmpdir, library);
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(outputMain));
}
Aggregations