Search in sources :

Example 6 with BuildShouldFail

use of fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail in project repairnator by Spirals-Team.

the class TestGatherTestInformation method testGatherTestInformationWhenErroring.

@Test
public void testGatherTestInformationWhenErroring() throws IOException {
    // surli/failingProject build
    int buildId = 208240908;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_gathertest");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    System.out.println("Dirpath : " + tmpDirPath);
    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");
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    GatherTestInformation gatherTestInformation = new GatherTestInformation(inspector, new BuildShouldFail(), false);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(gatherTestInformation);
    cloneStep.execute();
    assertThat(gatherTestInformation.shouldStop, is(false));
    assertThat(gatherTestInformation.getPipelineState(), is(PipelineState.HASTESTERRORS));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.HASTESTERRORS));
    assertThat(jobStatus.getFailingModulePath(), is(repoDir.getCanonicalPath()));
    assertThat(gatherTestInformation.getNbTotalTests(), is(26));
    assertThat(gatherTestInformation.getNbFailingTests(), is(0));
    assertThat(gatherTestInformation.getNbErroringTests(), is(5));
    assertThat(gatherTestInformation.getNbSkippingTests(), is(0));
    Set<String> failureNames = jobStatus.getMetrics().getFailureNames();
    assertThat("Got the following errors: " + StringUtils.join(failureNames, ","), failureNames.contains("java.lang.NullPointerException"), is(true));
    assertThat(failureNames.size(), is(3));
    assertThat(jobStatus.getFailureLocations().size(), is(4));
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) BuildShouldFail(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) GatherTestInformation(fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) File(java.io.File) Test(org.junit.Test)

Example 7 with BuildShouldFail

use of fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail in project repairnator by Spirals-Team.

the class TestNopolRepair method testNopolRepair.

@Test
public void testNopolRepair() throws IOException {
    // surli/failingProject build
    int buildId = 207890790;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_nopolrepair");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    System.out.println("Dirpath : " + tmpDirPath);
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, "");
    ProjectInspector inspector = new ProjectInspector(toBeInspected, tmpDir.getAbsolutePath(), null, null);
    CloneRepository cloneStep = new CloneRepository(inspector);
    NopolRepair nopolRepair = new NopolRepair(inspector);
    NopolRepair.TOTAL_MAX_TIME = 2;
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(new GatherTestInformation(inspector, new BuildShouldFail(), false)).setNextStep(new ComputeClasspath(inspector)).setNextStep(new ComputeSourceDir(inspector, false)).setNextStep(nopolRepair);
    cloneStep.execute();
    assertThat(nopolRepair.shouldStop, is(false));
    assertThat(nopolRepair.getPipelineState(), is(PipelineState.NOPOL_PATCHED));
    assertThat(nopolRepair.getNopolInformations().size(), is(11));
// The following assertion is working when the test is launched in the current module
// however it does not work properly when launched from the root module,
// so it breaks the CI. The nopol logs should be treaten differently inside Nopol
// File nopolLog = new File(inspector.getRepoLocalPath(), "repairnator.nopol.log");
// assertTrue(nopolLog.exists());
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) BuildShouldFail(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) GatherTestInformation(fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) File(java.io.File) Test(org.junit.Test)

Example 8 with BuildShouldFail

use of fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail in project repairnator by Spirals-Team.

the class TestNPERepair method testNPERepair.

@Test
public void testNPERepair() throws IOException {
    // surli/failingProject build
    int buildId = 252712792;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_nperepair");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    System.out.println("Dirpath : " + tmpDirPath);
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, "");
    ProjectInspector inspector = new ProjectInspector(toBeInspected, tmpDir.getAbsolutePath(), null, null);
    CloneRepository cloneStep = new CloneRepository(inspector);
    NPERepair npeRepair = new NPERepair(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(new GatherTestInformation(inspector, new BuildShouldFail(), false)).setNextStep(npeRepair);
    cloneStep.execute();
    assertThat(npeRepair.shouldStop, is(false));
    assertThat(npeRepair.getPipelineState(), is(PipelineState.NPEFIX_PATCHED));
    assertThat(inspector.getJobStatus().getNpeFixPatches().size(), is(6));
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) GatherTestInformation(fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) BuildShouldFail(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) File(java.io.File) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Test(org.junit.Test)

Aggregations

CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)8 BuildShouldFail (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail)8 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)8 Build (fr.inria.jtravis.entities.Build)6 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)6 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)6 File (java.io.File)6 Path (java.nio.file.Path)6 Test (org.junit.Test)6 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)4 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)4 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)2 BuildShouldPass (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass)2 CommitPatch (fr.inria.spirals.repairnator.process.step.push.CommitPatch)2 InitRepoToPush (fr.inria.spirals.repairnator.process.step.push.InitRepoToPush)2 PushIncriminatedBuild (fr.inria.spirals.repairnator.process.step.push.PushIncriminatedBuild)2 ErrorNotifier (fr.inria.spirals.repairnator.notifier.ErrorNotifier)1 CheckoutBuggyBuildSourceCode (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuildSourceCode)1 FailureLocation (fr.inria.spirals.repairnator.process.testinformation.FailureLocation)1 FailureType (fr.inria.spirals.repairnator.process.testinformation.FailureType)1