use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class NopolSerializer method serializeData.
@Override
public void serializeData(ProjectInspector inspector) {
if (inspector.getJobStatus().getNopolInformations() != null) {
BuildToBeInspected buildToBeInspected = inspector.getBuildToBeInspected();
List<SerializedData> allDatas = new ArrayList<>();
for (NopolInformation nopolInformation : inspector.getJobStatus().getNopolInformations()) {
if (nopolInformation.getPatches().isEmpty()) {
SerializedData data = new SerializedData(this.serializeNopolInfoAsList(buildToBeInspected, nopolInformation, null, 0), this.serializeNopolInfoAsJson(buildToBeInspected, nopolInformation, null, 0));
allDatas.add(data);
} else {
int patchNumber = 1;
for (PatchAndDiff patchAndDiff : nopolInformation.getPatches()) {
SerializedData data = new SerializedData(this.serializeNopolInfoAsList(buildToBeInspected, nopolInformation, patchAndDiff, patchNumber), this.serializeNopolInfoAsJson(buildToBeInspected, nopolInformation, patchAndDiff, patchNumber));
allDatas.add(data);
patchNumber++;
}
}
for (SerializerEngine engine : this.getEngines()) {
engine.serialize(allDatas, this.getType());
}
}
}
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestProjectInspector method testRepairingWithNPEFix.
@Test
public void testRepairingWithNPEFix() throws IOException, GitAPIException {
// surli/failingProject npe
int buildId = 253130137;
Path tmpDirPath = Files.createTempDirectory("test_complete_npe");
File tmpDir = tmpDirPath.toFile();
tmpDir.deleteOnExit();
Build failingBuild = BuildHelper.getBuildFromId(buildId, null);
BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, null, ScannedBuildStatus.ONLY_FAIL, "testnpe");
List<AbstractDataSerializer> serializers = new ArrayList<>();
List<AbstractNotifier> notifiers = new ArrayList<>();
List<SerializerEngine> serializerEngines = new ArrayList<>();
SerializerEngine serializerEngine = mock(SerializerEngine.class);
serializerEngines.add(serializerEngine);
List<NotifierEngine> notifierEngines = new ArrayList<>();
NotifierEngine notifierEngine = mock(NotifierEngine.class);
notifierEngines.add(notifierEngine);
serializers.add(new InspectorSerializer(serializerEngines));
serializers.add(new NopolSerializer(serializerEngines));
notifiers.add(new PatchNotifier(notifierEngines));
RepairnatorConfig config = RepairnatorConfig.getInstance();
config.setLauncherMode(LauncherMode.REPAIR);
ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
inspector.run();
JobStatus jobStatus = inspector.getJobStatus();
assertThat(jobStatus.getAstorStatus(), is(AstorOutputStatus.MAX_GENERATION));
assertThat(jobStatus.getPipelineState(), is(PipelineState.NOPOL_PATCHED));
assertThat(jobStatus.getPushState(), is(PushState.REPAIR_INFO_COMMITTED));
assertThat(jobStatus.getFailureLocations().size(), is(1));
assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
assertThat(jobStatus.isHasBeenPatched(), is(true));
assertThat(jobStatus.getNpeFixPatches().size(), is(6));
// Nopol and NPEFix
verify(notifierEngine, times(2)).notify(anyString(), anyString());
verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.NOPOL));
Git gitDir = Git.open(new File(inspector.getRepoToPushLocalPath()));
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("Automatic repair"));
commit = iterator.next();
assertThat(commit.getShortMessage(), containsString("Bug commit"));
assertThat(iterator.hasNext(), is(false));
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestProjectInspector method testPatchFailingProjectM70.
@Ignore
@Test
public void testPatchFailingProjectM70() throws IOException, GitAPIException {
// surli/failingProject only-one-failing
int buildId = 269201915;
Path tmpDirPath = Files.createTempDirectory("test_complete");
File tmpDir = tmpDirPath.toFile();
tmpDir.deleteOnExit();
Build failingBuild = BuildHelper.getBuildFromId(buildId, null);
BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, null, ScannedBuildStatus.ONLY_FAIL, "test");
List<AbstractDataSerializer> serializers = new ArrayList<>();
List<AbstractNotifier> notifiers = new ArrayList<>();
List<SerializerEngine> serializerEngines = new ArrayList<>();
SerializerEngine serializerEngine = mock(SerializerEngine.class);
serializerEngines.add(serializerEngine);
List<NotifierEngine> notifierEngines = new ArrayList<>();
NotifierEngine notifierEngine = mock(NotifierEngine.class);
notifierEngines.add(notifierEngine);
serializers.add(new InspectorSerializer(serializerEngines));
serializers.add(new NopolSerializer(serializerEngines));
notifiers.add(new PatchNotifier(notifierEngines));
RepairnatorConfig config = RepairnatorConfig.getInstance();
config.setLauncherMode(LauncherMode.REPAIR);
ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
inspector.run();
JobStatus jobStatus = inspector.getJobStatus();
assertThat(jobStatus.getAstorStatus(), is(AstorOutputStatus.STOP_BY_PATCH_FOUND));
assertThat(jobStatus.getPipelineState(), is(PipelineState.NOPOL_NOTPATCHED));
assertThat(jobStatus.getPushState(), is(PushState.REPAIR_INFO_COMMITTED));
assertThat(jobStatus.getFailureLocations().size(), is(1));
assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
// notify for Astor, NPEFix and Nopol
verify(notifierEngine, times(3)).notify(anyString(), anyString());
verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.NOPOL));
Git gitDir = Git.open(new File(inspector.getRepoToPushLocalPath()));
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("Automatic repair"));
commit = iterator.next();
assertThat(commit.getShortMessage(), containsString("Bug commit"));
assertThat(iterator.hasNext(), is(false));
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestBuildProject method testBuildProject.
@Test
public void testBuildProject() 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_build");
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.getM2LocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/.m2");
when(inspector.getGitHelper()).thenReturn(new GitHelper());
JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
when(inspector.getJobStatus()).thenReturn(jobStatus);
CloneRepository cloneStep = new CloneRepository(inspector);
BuildProject buildStep = new BuildProject(inspector);
cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(buildStep);
cloneStep.execute();
assertThat(buildStep.shouldStop, is(false));
assertThat(buildStep.getPipelineState(), is(PipelineState.BUILDABLE));
assertThat(jobStatus.getPipelineState(), is(PipelineState.BUILDABLE));
}
use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.
the class TestCloneRepositoryStep method testCloneMasterBuild.
@Test
public void testCloneMasterBuild() 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_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));
Git gitDir = Git.open(new File(tmpDir, "repo"));
Ref ref = gitDir.getRepository().exactRef("HEAD");
assertThat(ref.isSymbolic(), is(true));
ref = ref.getTarget();
// no check out yet
assertThat(ref.getObjectId().getName(), not(build.getCommit().getSha()));
}
Aggregations