public void testPantsIdeaPluginGoal() throws Throwable {
    assertEmpty(ModuleManager.getInstance(myProject).getModules());

    /** Check whether Pants supports `idea-plugin` goal. */
    PantsUtil.findPantsExecutable(getProjectFolder().getPath());
    final GeneralCommandLine commandLinePantsGoals =
        PantsUtil.defaultCommandLine(getProjectFolder().getPath());
    commandLinePantsGoals.addParameter("goals");
    final ProcessOutput cmdOutputGoals =
        PantsUtil.getCmdOutput(commandLinePantsGoals.withWorkDirectory(getProjectFolder()), null);
    assertEquals(commandLinePantsGoals.toString() + " failed", 0, cmdOutputGoals.getExitCode());
    if (!cmdOutputGoals.getStdout().contains("idea-plugin")) {
      return;
    }

    /** Generate idea project via `idea-plugin` goal. */
    final GeneralCommandLine commandLine =
        PantsUtil.defaultCommandLine(getProjectFolder().getPath());
    final File outputFile = FileUtil.createTempFile("project_dir_location", ".out");
    commandLine.addParameters(
        "idea-plugin",
        "--no-open",
        "--output-file=" + outputFile.getPath(),
        "testprojects/tests/java/org/pantsbuild/testproject/::");
    final ProcessOutput cmdOutput =
        PantsUtil.getCmdOutput(commandLine.withWorkDirectory(getProjectFolder()), null);
    assertEquals(commandLine.toString() + " failed", 0, cmdOutput.getExitCode());
    String projectDir = FileUtil.loadFile(outputFile);

    myProject = ProjectUtil.openProject(projectDir + "/project.ipr", myProject, false);
    // Invoke post startup activities.
    UIUtil.dispatchAllInvocationEvents();
    /**
     * Under unit test mode, {@link com.intellij.ide.impl.ProjectUtil#openProject} will force open a
     * project in a new window, so Project SDK has to be reset. In practice, this is not needed.
     */
    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              @Override
              public void run() {
                final JavaSdk javaSdk = JavaSdk.getInstance();
                ProjectRootManager.getInstance(myProject)
                    .setProjectSdk(
                        ProjectJdkTable.getInstance().getSdksOfType(javaSdk).iterator().next());
              }
            });

    JUnitConfiguration runConfiguration =
        generateJUnitConfiguration(
            "testprojects_tests_java_org_pantsbuild_testproject_matcher_matcher",
            "org.pantsbuild.testproject.matcher.MatcherTest",
            null);

    assertAndRunPantsMake(runConfiguration);
    assertSuccessfulJUnitTest(runConfiguration);
  }
  @Override
  protected void doOpenProject(
      @NotNull String projectPath, Project projectToClose, boolean forceOpenInNewFrame) {
    if (new File(projectPath).isDirectory()
        && !new File(projectPath, Project.DIRECTORY_STORE_FOLDER).exists()) {
      VirtualFile projectDir =
          LocalFileSystem.getInstance()
              .findFileByPath(FileUtil.toSystemIndependentName(projectPath));
      PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstanceIfItExists();
      if (projectDir != null && processor != null) {
        processor.doOpenProject(projectDir, projectToClose, forceOpenInNewFrame);
        return;
      }
    }

    ProjectUtil.openProject(projectPath, projectToClose, forceOpenInNewFrame);
  }
 public boolean processCheckedOutDirectory(Project project, File directory) {
   File[] files =
       directory.listFiles(
           (FilenameFilter) new GlobFilenameFilter("*" + ProjectFileType.DOT_DEFAULT_EXTENSION));
   if (files != null && files.length > 0) {
     int rc =
         Messages.showYesNoDialog(
             project,
             VcsBundle.message("checkout.open.project.prompt", files[0].getPath()),
             VcsBundle.message("checkout.title"),
             Messages.getQuestionIcon());
     if (rc == 0) {
       ProjectUtil.openProject(files[0].getPath(), project, false);
     }
     return true;
   }
   return false;
 }