Пример #1
0
  private Callable<Integer> startCompilingMavenProject(TmcProjectInfo projectInfo) {
    File projectDir = projectInfo.getProjectDirAsFile();

    String goal = "test-compile";
    final InputOutput inOut = IOProvider.getDefault().getIO(projectInfo.getProjectName(), false);

    final ProcessRunner runner =
        new MavenRunBuilder()
            .setProjectDir(projectDir)
            .addGoal(goal)
            .setIO(inOut)
            .createProcessRunner();

    return new Callable<Integer>() {
      @Override
      public Integer call() throws Exception {
        try {
          ProcessResult result = runner.call();
          int ret = result.statusCode;
          if (ret != 0) {
            inOut.select();
          }
          return ret;
        } catch (Exception ex) {
          inOut.select();
          throw ex;
        }
      }
    };
  }
Пример #2
0
  private Callable<Integer> startCompilingMakefileProject(TmcProjectInfo projectInfo) {
    /* This solution is pretty much copied from the pre-existing Maven option.
     * I have no idea how well it will work, but this is a start.
     * --kviiri */
    Project project = projectInfo.getProject();
    FileObject makeFile = project.getProjectDirectory().getFileObject("Makefile");
    File workDir = projectInfo.getProjectDirAsFile();

    if (makeFile == null) {
      throw new RuntimeException("Project has no Makefile");
    }
    String[] command = {"make", "test"};

    final InputOutput io = IOProvider.getDefault().getIO(projectInfo.getProjectName(), false);
    final ProcessRunner runner = new ProcessRunner(command, workDir, io);
    return new Callable<Integer>() {
      @Override
      public Integer call() throws Exception {
        try {
          ProcessResult result = runner.call();
          int ret = result.statusCode;
          if (ret != 0) {
            io.select();
          }
          return ret;
        } catch (Exception ex) {
          io.select();
          throw ex;
        }
      }
    };
  }
Пример #3
0
  private void startRunningMakefileProjectTests(
      final TmcProjectInfo projectInfo, final boolean withValgrind) {
    final File testDir = projectInfo.getProjectDirAsFile();
    String[] command;
    if (withValgrind) {
      command =
          new String[] {
            "valgrind",
            "--log-file=valgrind.log",
            "." + File.separatorChar + "test" + File.separatorChar + "test"
          };
    } else {
      // Todo: why does this need testDir.getAbsolutePath()? --kviiri
      command =
          new String[] {
            testDir.getAbsolutePath() + File.separatorChar + "test" + File.separatorChar + "test"
          };
    }
    ProcessRunner runner =
        new ProcessRunner(
            command, testDir, IOProvider.getDefault().getIO(projectInfo.getProjectName(), false));

    BgTask.start(
        "Running tests",
        runner,
        new BgTaskListener<ProcessResult>() {
          @Override
          public void bgTaskReady(ProcessResult result) {
            CTestResultParser parser =
                new CTestResultParser(
                    new File(testDir.getAbsolutePath() + "/tmc_test_results.xml"),
                    withValgrind ? new File(testDir.getAbsolutePath() + "/valgrind.log") : null,
                    null);
            try {
              parser.parseTestOutput();
            } catch (Exception e) {
              dialogDisplayer.displayError(
                  "Failed to read test results:\n" + e.getClass() + " " + e.getMessage());
              return;
            }
            boolean canSubmit = submitAction.enable(projectInfo.getProject());
            List<TestCaseResult> results = parser.getTestCaseResults();
            resultDisplayer.showLocalRunResult(
                results,
                canSubmit,
                new Runnable() {
                  @Override
                  public void run() {
                    submitAction.performAction(projectInfo.getProject());
                  }
                });
          }

          @Override
          public void bgTaskCancelled() {}

          @Override
          public void bgTaskFailed(Throwable ex) {
            if (withValgrind) {
              startRunningMakefileProjectTests(projectInfo, false);
            } else {
              dialogDisplayer.displayError("Failed to run tests:\n" + ex.getMessage());
            }
          }
        });
  }