Search in sources :

Example 41 with BuildToBeInspected

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

the class TestProjectInspector method testFailingProjectNotBuildable.

@Test
public void testFailingProjectNotBuildable() throws IOException, GitAPIException {
    // surli/failingProject only-one-failing
    int buildId = 228303218;
    Path tmpDirPath = Files.createTempDirectory("test_complete2");
    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.NOTBUILDABLE));
    assertThat(jobStatus.getPushState(), is(PushState.NONE));
    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)

Example 42 with BuildToBeInspected

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

the class TestProjectInspector method testPatchFailingProject.

@Test
public void testPatchFailingProject() throws IOException, GitAPIException {
    // surli/failingProject only-one-failing
    int buildId = 208897371;
    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.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));
    String remoteBranchName = "surli-failingProject-208897371-20170308-040702";
    assertEquals(remoteBranchName, inspector.getRemoteBranchName());
    verify(notifierEngine, times(1)).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) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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 43 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected 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 44 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected 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)

Example 45 with BuildToBeInspected

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

the class TestBuildProject method testBuildProjectWithPomNotInRoot.

@Test
public void testBuildProjectWithPomNotInRoot() throws IOException {
    int buildId = 218036343;
    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 = new ProjectInspector(toBeInspected, tmpDir.getAbsolutePath(), Collections.EMPTY_LIST, Collections.EMPTY_LIST);
    JobStatus jobStatus = inspector.getJobStatus();
    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));
}
Also used : Path(java.nio.file.Path) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) File(java.io.File) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Test(org.junit.Test)

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