public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage : TestMain mpsProject"); return; } File projectFile = new File(args[0]); if (!projectFile.exists()) { System.out.println("Can't find a file " + projectFile); return; } TestResult result = testProject(projectFile); System.exit(result.isOk() ? 0 : 1); }
/** * Null result means no problems, not null result contains error description. * * @param projectFile * @return */ public static TestResult testProject( File projectFile, boolean isRunnable, String[] configurations) { com.intellij.openapi.diagnostic.Logger.setFactory(LoggerFactory.getInstance()); IdeMain.setTestMode(TestMode.CORE_TEST); long start = System.currentTimeMillis(); configureMPS(); System.out.println("loading project " + projectFile + "..."); if (!projectFile.exists()) { throw new RuntimeException("Can't find a project in file " + projectFile.getAbsolutePath()); } final Project project = loadProject(projectFile); TestResult result = new ProjectTester(project, isRunnable).testProject(configurations); ThreadUtils.runInUIThreadAndWait( new Runnable() { public void run() { project.dispose(); IdeEventQueue.getInstance().flushQueue(); gc(); } }); result.dump(System.out); if (!result.isOk()) { if (result.hasGenerationErrors()) { System.out.println("there were " + result.myGenerationErrors.size() + " generation error"); for (String error : result.myGenerationErrors) { System.out.println(error); } } if (result.hasGenerationWarnings()) { System.out.println( "there were " + result.myGenerationWarnings.size() + " generation warnings"); for (String warning : result.myGenerationWarnings) { System.out.println(warning); } } if (result.hasCompilationProblems()) { System.out.println( "there were " + result.myCompilationProblems.size() + " compilation problems"); for (String compilationProblem : result.myCompilationProblems) { System.out.println(compilationProblem); } } } System.out.println("testing took " + (System.currentTimeMillis() - start) + " ms"); return result; }