Search in sources :

Example 1 with BuildShouldPass

use of fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass 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 2 with BuildShouldPass

use of fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass 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 3 with BuildShouldPass

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

the class ProjectInspector4Bears method run.

public void run() {
    AbstractStep firstStep;
    AbstractStep cloneRepo = new CloneRepository(this);
    if (this.getBuildToBeInspected().getStatus() == ScannedBuildStatus.FAILING_AND_PASSING) {
        cloneRepo.setNextStep(new CheckoutBuggyBuild(this)).setNextStep(new ComputeSourceDir(this, true)).setNextStep(new ComputeTestDir(this)).setNextStep(new ResolveDependency(this)).setNextStep(new BuildProject(this, BuildProject.class.getSimpleName() + "PreviousBuild")).setNextStep(new TestProject(this, TestProject.class.getSimpleName() + "PreviousBuild")).setNextStep(new GatherTestInformation(this, new BuildShouldFail(), false, GatherTestInformation.class.getSimpleName() + "PreviousBuild")).setNextStep(new InitRepoToPush(this)).setNextStep(new ComputeClasspath(this)).setNextStep(new NopolRepair(this)).setNextStep(new CommitPatch(this, false)).setNextStep(new CheckoutPatchedBuild(this)).setNextStep(new BuildProject(this, BuildProject.class.getSimpleName() + "Build")).setNextStep(new TestProject(this, TestProject.class.getSimpleName() + "Build")).setNextStep(new GatherTestInformation(this, new BuildShouldPass(), true, GatherTestInformation.class.getSimpleName() + "Build")).setNextStep(new PushIncriminatedBuild(this)).setNextStep(new CommitPatch(this, true));
    } else {
        if (this.getBuildToBeInspected().getStatus() == ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES) {
            cloneRepo.setNextStep(new CheckoutPatchedBuild(this)).setNextStep(new ComputeSourceDir(this, true)).setNextStep(new ComputeTestDir(this)).setNextStep(new CheckoutBuggyBuildSourceCode(this)).setNextStep(new ResolveDependency(this)).setNextStep(new BuildProject(this, BuildProject.class.getSimpleName() + "PreviousBuildSourceCode")).setNextStep(new TestProject(this, TestProject.class.getSimpleName() + "PreviousBuildSourceCode")).setNextStep(new GatherTestInformation(this, new BuildShouldFail(), false, GatherTestInformation.class.getSimpleName() + "PreviousBuildSourceCode")).setNextStep(new InitRepoToPush(this)).setNextStep(new ComputeClasspath(this)).setNextStep(new NopolRepair(this)).setNextStep(new CommitPatch(this, false)).setNextStep(new CheckoutPatchedBuild(this)).setNextStep(new BuildProject(this, BuildProject.class.getSimpleName() + "Build")).setNextStep(new TestProject(this, TestProject.class.getSimpleName() + "Build")).setNextStep(new GatherTestInformation(this, new BuildShouldPass(), true, GatherTestInformation.class.getSimpleName() + "Build")).setNextStep(new PushIncriminatedBuild(this)).setNextStep(new CommitPatch(this, true));
        } else {
            this.logger.debug("The pair of scanned builds is not interesting.");
            return;
        }
    }
    firstStep = cloneRepo;
    firstStep.setDataSerializer(this.getSerializers());
    firstStep.setNotifiers(this.getNotifiers());
    firstStep.setPipelineState(PipelineState.INIT);
    try {
        firstStep.execute();
    } catch (Exception e) {
        this.getJobStatus().addStepError("Unknown", e.getMessage());
        this.logger.debug("Exception catch while executing steps: ", e);
    }
}
Also used : CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) CheckoutBuggyBuildSourceCode(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuildSourceCode) BuildShouldFail(fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail) InitRepoToPush(fr.inria.spirals.repairnator.process.step.push.InitRepoToPush) 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)3 BuildShouldPass (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldPass)3 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)3 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)2 BuildShouldFail (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail)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 Build (fr.inria.jtravis.entities.Build)1 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)1 ErrorNotifier (fr.inria.spirals.repairnator.notifier.ErrorNotifier)1 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)1 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)1 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)1 CheckoutBuggyBuildSourceCode (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuildSourceCode)1 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)1 File (java.io.File)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1