Search in sources :

Example 6 with CheckoutBuggyBuild

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

the class TestComputeTestDir method testComputeTestDirWithReflexiveReferences.

@Test
public void testComputeTestDirWithReflexiveReferences() throws IOException {
    int buildId = 345990212;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("computetestdir");
    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());
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    ComputeTestDir computeTestDir = new ComputeTestDir(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(computeTestDir);
    cloneStep.execute();
    assertThat(computeTestDir.shouldStop, is(false));
    assertThat(computeTestDir.getPipelineState(), is(PipelineState.TESTDIRNOTCOMPUTED));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.TESTDIRNOTCOMPUTED));
}
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 7 with CheckoutBuggyBuild

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

the class TestGatherTestInformation method testGatherTestInformationWhenNotFailingWithPassingContract.

@Test
public void testGatherTestInformationWhenNotFailingWithPassingContract() 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);
    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 BuildShouldPass(), false);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(gatherTestInformation);
    cloneStep.execute();
    assertThat(gatherTestInformation.shouldStop, is(false));
    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) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildShouldPass(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass) 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 8 with CheckoutBuggyBuild

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

the class TestGatherTestInformation method testGatherTestInformationWhenFailing.

@Test
public void testGatherTestInformationWhenFailing() 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_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.HASTESTFAILURE));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.HASTESTFAILURE));
    assertThat(jobStatus.getFailingModulePath(), is(repoDir.getCanonicalPath()));
    assertThat(gatherTestInformation.getNbTotalTests(), is(98));
    assertThat(gatherTestInformation.getNbFailingTests(), is(26));
    assertThat(gatherTestInformation.getNbErroringTests(), is(5));
    assertThat(gatherTestInformation.getNbSkippingTests(), is(0));
    Set<String> failureNames = jobStatus.getMetrics().getFailureNames();
    assertThat(failureNames.contains("java.lang.StringIndexOutOfBoundsException"), is(true));
    assertThat(failureNames.size(), is(5));
    assertThat(jobStatus.getFailureLocations().size(), is(10));
}
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 9 with CheckoutBuggyBuild

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

the class TestTestProject method testTestProjectWhenFailing.

@Test
public void testTestProjectWhenFailing() 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_testproject");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    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);
    TestProject testProject = new TestProject(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(testProject);
    cloneStep.execute();
    assertThat(testProject.shouldStop, is(false));
    assertThat(testProject.getPipelineState(), is(PipelineState.TESTABLE));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.TESTABLE));
}
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) 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 10 with CheckoutBuggyBuild

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

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