Search in sources :

Example 1 with InspectorSerializer4Bears

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

the class Launcher method mainProcess.

private void mainProcess() throws IOException {
    LOGGER.info("Start by getting the build (buildId: " + this.config.getBuildId() + ") with the following config: " + this.config);
    this.getBuildToBeInspected();
    HardwareInfoSerializer hardwareInfoSerializer = new HardwareInfoSerializer(this.engines, this.config.getRunId(), this.config.getBuildId() + "");
    hardwareInfoSerializer.serialize();
    List<AbstractDataSerializer> serializers = new ArrayList<>();
    if (this.config.getLauncherMode() == LauncherMode.REPAIR) {
        serializers.add(new InspectorSerializer(this.engines));
        serializers.add(new InspectorTimeSerializer(this.engines));
    } else {
        serializers.add(new InspectorSerializer4Bears(this.engines));
        serializers.add(new InspectorTimeSerializer4Bears(this.engines));
    }
    serializers.add(new NopolSerializer(this.engines));
    serializers.add(new NPEFixSerializer(this.engines));
    serializers.add(new AstorSerializer(this.engines));
    serializers.add(new MetricsSerializer(this.engines));
    serializers.add(new PipelineErrorSerializer(this.engines));
    ProjectInspector inspector;
    if (config.getLauncherMode() == LauncherMode.BEARS) {
        inspector = new ProjectInspector4Bears(buildToBeInspected, this.config.getWorkspacePath(), serializers, this.notifiers);
    } else {
        inspector = new ProjectInspector(buildToBeInspected, this.config.getWorkspacePath(), serializers, this.notifiers);
    }
    inspector.run();
    LOGGER.info("Inspector is finished. The process will now exit.");
    System.exit(0);
}
Also used : InspectorTimeSerializer4Bears(fr.inria.spirals.repairnator.serializer.InspectorTimeSerializer4Bears) HardwareInfoSerializer(fr.inria.spirals.repairnator.serializer.HardwareInfoSerializer) InspectorSerializer4Bears(fr.inria.spirals.repairnator.serializer.InspectorSerializer4Bears) ArrayList(java.util.ArrayList) InspectorTimeSerializer(fr.inria.spirals.repairnator.serializer.InspectorTimeSerializer) ProjectInspector4Bears(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector4Bears) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) PipelineErrorSerializer(fr.inria.spirals.repairnator.serializer.PipelineErrorSerializer) AstorSerializer(fr.inria.spirals.repairnator.serializer.AstorSerializer) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) MetricsSerializer(fr.inria.spirals.repairnator.serializer.MetricsSerializer) NPEFixSerializer(fr.inria.spirals.repairnator.serializer.NPEFixSerializer)

Example 2 with InspectorSerializer4Bears

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

the class TestProjectInspector4Bears method testFailingPassingProject.

@Test
public void testFailingPassingProject() throws IOException, GitAPIException {
    int buildIdPassing = 203800961;
    int buildIdFailing = 203797975;
    Path tmpDirPath = Files.createTempDirectory("test_bears1");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build passingBuild = BuildHelper.getBuildFromId(buildIdPassing, null);
    Build failingBuild = BuildHelper.getBuildFromId(buildIdFailing, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, passingBuild, ScannedBuildStatus.FAILING_AND_PASSING, "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 InspectorSerializer4Bears(serializerEngines));
    notifiers.add(new FixerBuildNotifier(notifierEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.BEARS);
    ProjectInspector4Bears inspector = new ProjectInspector4Bears(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getPipelineState(), is(PipelineState.FIXERBUILDCASE1));
    assertThat(jobStatus.getPushState(), is(PushState.PATCH_COMMITTED));
    assertThat(inspector.isFixerBuildCase1(), is(true));
    assertThat(jobStatus.getFailureLocations().size(), is(1));
    assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
    verify(notifierEngine, times(1)).notify(anyString(), anyString());
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR4BEARS));
    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("Human patch"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Automatic repair"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : Path(java.nio.file.Path) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) InspectorSerializer4Bears(fr.inria.spirals.repairnator.serializer.InspectorSerializer4Bears) ArrayList(java.util.ArrayList) FixerBuildNotifier(fr.inria.spirals.repairnator.notifier.FixerBuildNotifier) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 3 with InspectorSerializer4Bears

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

the class TestProjectInspector4Bears method testPassingPassingProject.

@Test
public void testPassingPassingProject() throws IOException, GitAPIException {
    int buildIdPassing = 201938881;
    int buildIdPreviousPassing = 201938325;
    Path tmpDirPath = Files.createTempDirectory("test_bears2");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build passingBuild = BuildHelper.getBuildFromId(buildIdPassing, null);
    Build previousPassingBuild = BuildHelper.getBuildFromId(buildIdPreviousPassing, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(previousPassingBuild, passingBuild, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, "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 InspectorSerializer4Bears(serializerEngines));
    notifiers.add(new FixerBuildNotifier(notifierEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.BEARS);
    ProjectInspector4Bears inspector = new ProjectInspector4Bears(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getPipelineState(), is(PipelineState.FIXERBUILDCASE2));
    assertThat(jobStatus.getPushState(), is(PushState.PATCH_COMMITTED));
    assertThat(inspector.isFixerBuildCase2(), is(true));
    assertThat(jobStatus.getFailureLocations().size(), is(1));
    assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
    verify(notifierEngine, times(1)).notify(anyString(), anyString());
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR4BEARS));
    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("Human patch"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Automatic repair"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : Path(java.nio.file.Path) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) InspectorSerializer4Bears(fr.inria.spirals.repairnator.serializer.InspectorSerializer4Bears) ArrayList(java.util.ArrayList) FixerBuildNotifier(fr.inria.spirals.repairnator.notifier.FixerBuildNotifier) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)3 InspectorSerializer4Bears (fr.inria.spirals.repairnator.serializer.InspectorSerializer4Bears)3 ArrayList (java.util.ArrayList)3 Build (fr.inria.jtravis.entities.Build)2 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)2 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)2 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)2 FixerBuildNotifier (fr.inria.spirals.repairnator.notifier.FixerBuildNotifier)2 NotifierEngine (fr.inria.spirals.repairnator.notifier.engines.NotifierEngine)2 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)2 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)2 File (java.io.File)2 Path (java.nio.file.Path)2 Git (org.eclipse.jgit.api.Git)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 Test (org.junit.Test)2 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)1 ProjectInspector4Bears (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector4Bears)1 AstorSerializer (fr.inria.spirals.repairnator.serializer.AstorSerializer)1 HardwareInfoSerializer (fr.inria.spirals.repairnator.serializer.HardwareInfoSerializer)1