more tests for compiler

This commit is contained in:
Maxim Manuylov
2012-07-29 23:30:49 +04:00
committed by Evgeny Gerashchenko
parent 0813e6bc1c
commit a8cd11f0f9
6 changed files with 56 additions and 15 deletions
@@ -148,22 +148,30 @@ public abstract class CLICompiler<A extends CompilerArguments> {
* Useful main for derived command line tools
*/
public static void doMain(@NotNull CLICompiler compiler, @NotNull String[] args) {
ExitCode exitCode = doDoMain(compiler, args);
if (exitCode != OK) {
System.exit(exitCode.getCode());
}
}
@NotNull
public static ExitCode doDoMain(CLICompiler compiler, String[] args) {
try {
ExitCode rc = compiler.exec(System.out, args);
if (rc != OK) {
System.err.println("exec() finished with " + rc + " return code");
if (Boolean.parseBoolean(System.getProperty("kotlin.print.cmd.args"))) {
System.err.println("Command line arguments: ");
for (String arg : args) {
System.err.println(arg);
}
}
System.exit(rc.getCode());
}
if (Boolean.parseBoolean(System.getProperty("kotlin.print.cmd.args"))) {
System.out.println("Command line arguments:");
for (String arg : args) {
System.out.println(arg);
}
}
return rc;
}
catch (CompileEnvironmentException e) {
System.err.println(e.getMessage());
System.exit(INTERNAL_ERROR.getCode());
return INTERNAL_ERROR;
}
}
}