Search in sources :

Example 46 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.

the class TestCommitPatch method testPushHumanPatchSimpleCase.

@Test
public void testPushHumanPatchSimpleCase() throws IOException, GitAPIException, RepairnatorConfigException {
    // surli/failingProject build
    int buildId = 207924136;
    RepairnatorConfig repairnatorConfig = RepairnatorConfig.getInstance();
    repairnatorConfig.setClean(false);
    repairnatorConfig.setPush(true);
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_pushPatch");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, "");
    ProjectInspector inspector = mock(ProjectInspector.class);
    when(inspector.getWorkspace()).thenReturn(tmpDir.getAbsolutePath());
    when(inspector.getRepoLocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getRepoToPushLocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/repotopush");
    when(inspector.getBuildToBeInspected()).thenReturn(toBeInspected);
    when(inspector.getBuggyBuild()).thenReturn(build);
    when(inspector.getGitHelper()).thenReturn(new GitHelper());
    JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new InitRepoToPush(inspector)).setNextStep(new CommitPatch(inspector, true));
    cloneStep.execute();
    assertThat(jobStatus.getPushState(), is(PushState.PATCH_COMMITTED));
    Git gitDir = Git.open(new File(tmpDir, "repotopush"));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    assertThat(iterator.hasNext(), is(true));
    RevCommit commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("End of the repairnator process"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Human patch"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CloneRepository(fr.inria.spirals.repairnator.process.step.CloneRepository) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 47 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.

the class InspectorSerializer method serializeAsList.

private List<Object> serializeAsList(ProjectInspector inspector) {
    JobStatus jobStatus = inspector.getJobStatus();
    BuildToBeInspected buildToBeInspected = inspector.getBuildToBeInspected();
    Build build = inspector.getBuggyBuild();
    String state = this.getPrettyPrintState(inspector);
    String realState = (jobStatus.getPipelineState() != null) ? jobStatus.getPipelineState().name() : "null";
    String typeOfFailures = StringUtils.join(jobStatus.getMetrics().getFailureNames(), ",") + "";
    List<Object> dataCol = new ArrayList<Object>();
    dataCol.add(build.getId() + "");
    dataCol.add(build.getRepository().getSlug());
    dataCol.add(state);
    dataCol.add(build.getPullRequestNumber() + "");
    dataCol.add(Utils.formatCompleteDate(build.getFinishedAt()));
    dataCol.add(Utils.formatOnlyDay(build.getFinishedAt()));
    dataCol.add(realState);
    dataCol.add(Utils.getHostname());
    dataCol.add(Utils.formatCompleteDate(new Date()));
    dataCol.add(Utils.getTravisUrl(build.getId(), build.getRepository().getSlug()));
    dataCol.add(typeOfFailures);
    dataCol.add(buildToBeInspected.getRunId());
    return dataCol;
}
Also used : JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) Build(fr.inria.jtravis.entities.Build) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Date(java.util.Date)

Example 48 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.

the class InspectorSerializer method serializeAsJson.

private JsonElement serializeAsJson(ProjectInspector inspector) {
    JobStatus jobStatus = inspector.getJobStatus();
    BuildToBeInspected buildToBeInspected = inspector.getBuildToBeInspected();
    Build build = inspector.getBuggyBuild();
    String state = this.getPrettyPrintState(inspector);
    String realState = (jobStatus.getPipelineState() != null) ? jobStatus.getPipelineState().name() : "null";
    String typeOfFailures = StringUtils.join(jobStatus.getMetrics().getFailureNames(), ",");
    JsonObject result = new JsonObject();
    result.addProperty("buildId", build.getId());
    result.addProperty("repositoryName", build.getRepository().getSlug());
    result.addProperty("status", state);
    result.addProperty("prNumber", build.getPullRequestNumber());
    result.addProperty("buildFinishedDateStr", Utils.formatCompleteDate(build.getFinishedAt()));
    this.addDate(result, "buildFinishedDate", build.getFinishedAt());
    result.addProperty("buildFinishedDay", Utils.formatOnlyDay(build.getFinishedAt()));
    result.addProperty("realStatus", realState);
    result.addProperty("hostname", Utils.getHostname());
    result.addProperty("buildReproductionDateStr", Utils.formatCompleteDate(new Date()));
    this.addDate(result, "buildReproductionDate", new Date());
    result.addProperty("travisURL", Utils.getTravisUrl(build.getId(), build.getRepository().getSlug()));
    result.addProperty("typeOfFailures", typeOfFailures);
    result.addProperty("runId", buildToBeInspected.getRunId());
    result.addProperty("branchURL", jobStatus.getGitBranchUrl());
    return result;
}
Also used : JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) Build(fr.inria.jtravis.entities.Build) JsonObject(com.google.gson.JsonObject) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Date(java.util.Date)

Aggregations

BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)48 Build (fr.inria.jtravis.entities.Build)44 File (java.io.File)40 Path (java.nio.file.Path)40 Test (org.junit.Test)40 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)35 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)33 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)30 CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)24 Git (org.eclipse.jgit.api.Git)12 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)11 ArrayList (java.util.ArrayList)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)11 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)10 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)8 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)8 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)8 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7