use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class InspectorSerializer4Bears method serializeAsJson.
private JsonElement serializeAsJson(ProjectInspector inspector) {
JobStatus jobStatus = inspector.getJobStatus();
BuildToBeInspected buildToBeInspected = inspector.getBuildToBeInspected();
Build build = inspector.getPatchedBuild();
Build previousBuild = inspector.getBuggyBuild();
int previousBuildId = (previousBuild != null) ? previousBuild.getId() : -1;
String state = this.getPrettyPrintState(inspector);
String realState = (jobStatus.getPipelineState() != null) ? jobStatus.getPipelineState().name() : "null";
String typeOfFailures = StringUtils.join(jobStatus.getMetrics().getFailureNames(), ",");
String previousBuildSlug = (previousBuild != null) ? previousBuild.getRepository().getSlug() : "";
String committerEmail = (build.getCommit().getCommitterEmail() != null) ? build.getCommit().getCommitterEmail() : "-";
JsonObject result = new JsonObject();
result.addProperty("buildId", build.getId());
result.addProperty("previousBuildId", previousBuildId);
result.addProperty("scannedBuildStatus", buildToBeInspected.getStatus().name());
result.addProperty("status", state);
result.addProperty("realStatus", realState);
result.addProperty("checkoutType", inspector.getCheckoutType().name());
result.addProperty("typeOfFailures", typeOfFailures);
result.addProperty("repositoryName", build.getRepository().getSlug());
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("hostname", Utils.getHostname());
result.addProperty("buildReproductionDateStr", Utils.formatCompleteDate(new Date()));
this.addDate(result, "buildReproductionDate", new Date());
result.addProperty("buildTravisUrl", Utils.getTravisUrl(build.getId(), build.getRepository().getSlug()));
result.addProperty("previousBuildTravisUrl", Utils.getTravisUrl(previousBuildId, previousBuildSlug));
result.addProperty("committerEmail", committerEmail);
result.addProperty("runId", buildToBeInspected.getRunId());
return result;
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class InspectorSerializer4Bears method serializeAsList.
private List<Object> serializeAsList(ProjectInspector inspector) {
JobStatus jobStatus = inspector.getJobStatus();
BuildToBeInspected buildToBeInspected = inspector.getBuildToBeInspected();
Build build = inspector.getPatchedBuild();
Build previousBuild = inspector.getBuggyBuild();
int previousBuildId = (previousBuild != null) ? previousBuild.getId() : -1;
String state = this.getPrettyPrintState(inspector);
String realState = (jobStatus.getPipelineState() != null) ? jobStatus.getPipelineState().name() : "null";
String typeOfFailures = StringUtils.join(jobStatus.getMetrics().getFailureNames(), ",") + "";
String previousBuildSlug = (previousBuild != null) ? previousBuild.getRepository().getSlug() : "";
String committerEmail = (build.getCommit().getCommitterEmail() != null) ? build.getCommit().getCommitterEmail() : "-";
List<Object> dataCol = new ArrayList<Object>();
dataCol.add(build.getId() + "");
dataCol.add(previousBuildId + "");
dataCol.add(buildToBeInspected.getStatus().name());
dataCol.add(state);
dataCol.add(realState);
dataCol.add(inspector.getCheckoutType().name());
dataCol.add(typeOfFailures);
dataCol.add(build.getRepository().getSlug());
dataCol.add(build.getPullRequestNumber() + "");
dataCol.add(Utils.formatCompleteDate(build.getFinishedAt()));
dataCol.add(Utils.formatOnlyDay(build.getFinishedAt()));
dataCol.add(Utils.getHostname());
dataCol.add(Utils.formatCompleteDate(new Date()));
dataCol.add(Utils.getTravisUrl(build.getId(), build.getRepository().getSlug()));
dataCol.add(Utils.getTravisUrl(previousBuildId, previousBuildSlug));
dataCol.add(committerEmail);
dataCol.add(buildToBeInspected.getRunId());
return dataCol;
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestCloneRepositoryStep method testCloneBuildWithSubmodule.
@Test
public void testCloneBuildWithSubmodule() throws IOException {
// surli/failingProject build
int buildId = 355839305;
Build build = BuildHelper.getBuildFromId(buildId, null);
assertThat(build, notNullValue());
assertThat(buildId, is(build.getId()));
Path tmpDirPath = Files.createTempDirectory("test_clone");
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.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.execute();
assertThat(jobStatus.getPipelineState(), is(PipelineState.CLONABLE));
assertThat(cloneStep.getPipelineState(), is(PipelineState.CLONABLE));
assertThat(cloneStep.shouldStop, is(false));
File licenceInSubmodule = new File(tmpDirPath.toFile(), "repo/grakn-spec/LICENSE");
assertThat("Submodule are not supported", licenceInSubmodule.exists(), is(true));
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestComputeClasspath method testComputeClasspath.
@Test
public void testComputeClasspath() throws IOException {
// surli/failingProject build
int buildId = 201176013;
Build build = BuildHelper.getBuildFromId(buildId, null);
assertThat(build, notNullValue());
assertThat(buildId, is(build.getId()));
Path tmpDirPath = Files.createTempDirectory("test_computecp");
File tmpDir = tmpDirPath.toFile();
tmpDir.deleteOnExit();
File repoDir = new File(tmpDir, "repo");
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.getBuildToBeInspected()).thenReturn(toBeInspected);
when(inspector.getBuggyBuild()).thenReturn(build);
when(inspector.getM2LocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/.m2");
when(inspector.getGitHelper()).thenReturn(new GitHelper());
JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
jobStatus.setFailingModulePath(repoDir.getAbsolutePath());
when(inspector.getJobStatus()).thenReturn(jobStatus);
CloneRepository cloneStep = new CloneRepository(inspector);
ComputeClasspath computeClasspath = new ComputeClasspath(inspector);
cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(computeClasspath);
cloneStep.execute();
assertThat(computeClasspath.shouldStop, is(false));
assertThat(computeClasspath.getPipelineState(), is(PipelineState.CLASSPATHCOMPUTED));
assertThat(jobStatus.getPipelineState(), is(PipelineState.CLASSPATHCOMPUTED));
List<URL> expectedClasspath = new ArrayList<URL>();
URL classDir = new URL("file:" + repoDir.getAbsolutePath() + "/target/classes/");
URL testDir = new URL("file:" + repoDir.getAbsolutePath() + "/target/test-classes/");
URL junit = new URL("file:" + tmpDir.getAbsolutePath() + "/.m2/junit/junit/4.11/junit-4.11.jar");
URL hamcrest = new URL("file:" + tmpDir.getAbsolutePath() + "/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar");
expectedClasspath.add(classDir);
expectedClasspath.add(testDir);
expectedClasspath.add(junit);
expectedClasspath.add(hamcrest);
assertThat(jobStatus.getRepairClassPath(), is(expectedClasspath));
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestComputeSourceDir method testComputeSourceDir.
@Test
public void testComputeSourceDir() throws IOException {
// surli/failingProject build
int buildId = 207924136;
Build build = BuildHelper.getBuildFromId(buildId, null);
assertThat(build, notNullValue());
assertThat(buildId, is(build.getId()));
Path tmpDirPath = Files.createTempDirectory("test_computesourcedir");
File tmpDir = tmpDirPath.toFile();
tmpDir.deleteOnExit();
File repoDir = new File(tmpDir, "repo");
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.getBuildToBeInspected()).thenReturn(toBeInspected);
when(inspector.getBuggyBuild()).thenReturn(build);
when(inspector.getM2LocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/.m2");
when(inspector.getGitHelper()).thenReturn(new GitHelper());
JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
jobStatus.setFailingModulePath(repoDir.getAbsolutePath());
when(inspector.getJobStatus()).thenReturn(jobStatus);
CloneRepository cloneStep = new CloneRepository(inspector);
ComputeSourceDir computeSourceDir = new ComputeSourceDir(inspector, false);
cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(computeSourceDir);
cloneStep.execute();
assertThat(computeSourceDir.shouldStop, is(false));
assertThat(computeSourceDir.getPipelineState(), is(PipelineState.SOURCEDIRCOMPUTED));
assertThat(jobStatus.getPipelineState(), is(PipelineState.SOURCEDIRCOMPUTED));
assertThat(jobStatus.getRepairSourceDir(), is(new File[] { new File(repoDir.getAbsolutePath() + "/src/main/java") }));
}
Aggregations