Search in sources :

Example 16 with CheckoutBuggyBuild

use of fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild in project repairnator by Spirals-Team.

the class TestComputeSourceDir method testComputeSourceDirWithMultiModuleProject2.

@Test
public void testComputeSourceDirWithMultiModuleProject2() throws IOException {
    // Spirals-Team/librepair build
    int buildId = 225251586;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_computesourcedir2");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    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");
    jobStatus.setFailingModulePath(repoDir.getAbsolutePath() + "/a-module");
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    ComputeSourceDir computeSourceDir = new ComputeSourceDir(inspector, false);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(computeSourceDir);
    cloneStep.execute();
    assertThat(computeSourceDir.shouldStop, is(false));
    assertThat(computeSourceDir.getPipelineState(), is(PipelineState.SOURCEDIRCOMPUTED));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.SOURCEDIRCOMPUTED));
    assertThat(jobStatus.getRepairSourceDir(), is(new File[] { new File(repoDir.getAbsolutePath() + "/a-module/src/custom/folder") }));
}
Also used : Path(java.nio.file.Path) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) CheckoutPatchedBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) File(java.io.File) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Test(org.junit.Test)

Example 17 with CheckoutBuggyBuild

use of fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild in project repairnator by Spirals-Team.

the class TestGatherTestInformation method testGatherTestInformationWhenNotFailing.

@Test
public void testGatherTestInformationWhenNotFailing() throws IOException {
    // surli/failingProject build
    int buildId = 201176013;
    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(true));
    assertThat(gatherTestInformation.getPipelineState(), is(PipelineState.NOTFAILING));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.NOTFAILING));
    assertThat(jobStatus.getFailingModulePath(), is(tmpDir.getAbsolutePath() + "/repo"));
    assertThat(gatherTestInformation.getNbTotalTests(), is(1));
    assertThat(gatherTestInformation.getNbFailingTests(), is(0));
    assertThat(gatherTestInformation.getNbErroringTests(), is(0));
    assertThat(gatherTestInformation.getNbSkippingTests(), is(0));
    Set<String> failureNames = jobStatus.getMetrics().getFailureNames();
    assertThat(failureNames.size(), is(0));
    assertThat(jobStatus.getFailureLocations().size(), is(0));
}
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 18 with CheckoutBuggyBuild

use of fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild in project repairnator by Spirals-Team.

the class TestGatherTestInformation method testGatherTestInformationOnlyOneErroring.

@Test
public void testGatherTestInformationOnlyOneErroring() throws IOException {
    // surli/failingProject build
    int buildId = 208897371;
    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(8));
    assertThat(gatherTestInformation.getNbFailingTests(), is(0));
    assertThat(gatherTestInformation.getNbErroringTests(), is(1));
    assertThat(gatherTestInformation.getNbSkippingTests(), is(0));
    Set<String> failureNames = jobStatus.getMetrics().getFailureNames();
    assertThat("failure names" + StringUtils.join(failureNames.toArray()), failureNames.contains("java.lang.StringIndexOutOfBoundsException"), is(true));
    assertThat(failureNames.size(), is(1));
    assertThat(jobStatus.getFailureLocations().size(), is(1));
    FailureLocation expectedFailureLocation = new FailureLocation("nopol_examples.nopol_example_1.NopolExampleTest");
    FailureType failureType = new FailureType("java.lang.StringIndexOutOfBoundsException", "String index out of range: -5", true);
    expectedFailureLocation.addFailure(failureType);
    expectedFailureLocation.addErroringMethod("nopol_examples.nopol_example_1.NopolExampleTest#test5");
    FailureLocation actualLocation = jobStatus.getFailureLocations().iterator().next();
    assertThat(actualLocation, is(expectedFailureLocation));
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) FailureType(fr.inria.spirals.repairnator.process.testinformation.FailureType) FailureLocation(fr.inria.spirals.repairnator.process.testinformation.FailureLocation) 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 19 with CheckoutBuggyBuild

use of fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild 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 20 with CheckoutBuggyBuild

use of fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild 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)

Aggregations

CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)25 Build (fr.inria.jtravis.entities.Build)23 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)23 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)23 File (java.io.File)23 Path (java.nio.file.Path)23 Test (org.junit.Test)23 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)21 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)20 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)9 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)9 BuildShouldFail (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail)8 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)3 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)3 BuildShouldPass (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass)3 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 Git (org.eclipse.jgit.api.Git)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2