Search in sources :

Example 1 with AbstractDataSerializer

use of fr.inria.spirals.repairnator.serializer.AbstractDataSerializer 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));
}
Also used : PatchNotifier(fr.inria.spirals.repairnator.notifier.PatchNotifier) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) ArrayList(java.util.ArrayList) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Path(java.nio.file.Path) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) Git(org.eclipse.jgit.api.Git) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Test(org.junit.Test)

Example 2 with AbstractDataSerializer

use of fr.inria.spirals.repairnator.serializer.AbstractDataSerializer 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));
}
Also used : PatchNotifier(fr.inria.spirals.repairnator.notifier.PatchNotifier) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) ArrayList(java.util.ArrayList) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Path(java.nio.file.Path) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) Git(org.eclipse.jgit.api.Git) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with AbstractDataSerializer

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

the class ProjectInspector method run.

public void run() {
    if (this.buildToBeInspected.getStatus() != ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES) {
        AbstractStep cloneRepo = new CloneRepository(this);
        cloneRepo.setNextStep(new CheckoutBuggyBuild(this)).setNextStep(new ComputeSourceDir(this, true)).setNextStep(new ComputeTestDir(this)).setNextStep(new ResolveDependency(this)).setNextStep(new BuildProject(this)).setNextStep(new TestProject(this)).setNextStep(new GatherTestInformation(this, new BuildShouldFail(), false)).setNextStep(new InitRepoToPush(this)).setNextStep(new PushIncriminatedBuild(this)).setNextStep(new NPERepair(this)).setNextStep(new ComputeClasspath(this)).setNextStep(new ComputeSourceDir(this, false)).setNextStep(new AstorRepair(this)).setNextStep(new NopolRepair(this)).setNextStep(new CommitPatch(this, false)).setNextStep(new CheckoutPatchedBuild(this)).setNextStep(new BuildProject(this)).setNextStep(new TestProject(this)).setNextStep(new GatherTestInformation(this, new BuildShouldPass(), true)).setNextStep(new CommitPatch(this, true));
        cloneRepo.setDataSerializer(this.serializers);
        cloneRepo.setNotifiers(this.notifiers);
        cloneRepo.setPipelineState(PipelineState.INIT);
        try {
            cloneRepo.execute();
        } catch (Exception e) {
            this.jobStatus.addStepError("Unknown", e.getMessage());
            this.logger.error("Exception catch while executing steps: ", e);
            this.jobStatus.setFatalError(e);
            ErrorNotifier errorNotifier = ErrorNotifier.getInstance();
            if (errorNotifier != null) {
                errorNotifier.observe(this);
            }
            for (AbstractDataSerializer serializer : this.serializers) {
                serializer.serializeData(this);
            }
        }
    } else {
        this.logger.debug("Scanned build is not a failing build.");
    }
}
Also used : ErrorNotifier(fr.inria.spirals.repairnator.notifier.ErrorNotifier) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) BuildShouldFail(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail) InitRepoToPush(fr.inria.spirals.repairnator.process.step.push.InitRepoToPush) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildShouldPass(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass) CheckoutPatchedBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild) GatherTestInformation(fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation) PushIncriminatedBuild(fr.inria.spirals.repairnator.process.step.push.PushIncriminatedBuild) CommitPatch(fr.inria.spirals.repairnator.process.step.push.CommitPatch)

Example 4 with AbstractDataSerializer

use of fr.inria.spirals.repairnator.serializer.AbstractDataSerializer 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 5 with AbstractDataSerializer

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

the class TestProjectInspector method testSpoonException.

@Test
public void testSpoonException() throws IOException, GitAPIException {
    // surli/failingProject only-one-failing
    int buildId = 355743087;
    Path tmpDirPath = Files.createTempDirectory("test_spoonexception");
    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);
    serializers.add(new InspectorSerializer(serializerEngines));
    serializers.add(new NopolSerializer(serializerEngines));
    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.getPipelineState(), is(PipelineState.NOPOL_NOTPATCHED));
    assertThat(jobStatus.getNopolInformations().get(0).getStatus(), is(NopolStatus.EXCEPTION));
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
}
Also used : Path(java.nio.file.Path) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) ArrayList(java.util.ArrayList) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Test(org.junit.Test)

Aggregations

AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)9 ArrayList (java.util.ArrayList)8 Build (fr.inria.jtravis.entities.Build)7 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)7 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)7 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)7 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)7 File (java.io.File)7 Path (java.nio.file.Path)7 Test (org.junit.Test)7 InspectorSerializer (fr.inria.spirals.repairnator.serializer.InspectorSerializer)6 NopolSerializer (fr.inria.spirals.repairnator.serializer.NopolSerializer)6 NotifierEngine (fr.inria.spirals.repairnator.notifier.engines.NotifierEngine)5 Git (org.eclipse.jgit.api.Git)5 RevCommit (org.eclipse.jgit.revwalk.RevCommit)5 PatchNotifier (fr.inria.spirals.repairnator.notifier.PatchNotifier)3 InspectorSerializer4Bears (fr.inria.spirals.repairnator.serializer.InspectorSerializer4Bears)3 FixerBuildNotifier (fr.inria.spirals.repairnator.notifier.FixerBuildNotifier)2 ErrorNotifier (fr.inria.spirals.repairnator.notifier.ErrorNotifier)1