Search in sources :

Example 41 with JobStatus

use of fr.inria.spirals.repairnator.process.inspectors.JobStatus in project repairnator by Spirals-Team.

the class TestCheckoutBuild method testCheckoutBuggyBuild.

@Test
public void testCheckoutBuggyBuild() throws IOException, GitAPIException, RepairnatorConfigException {
    // surli/failingProject build
    int buildId = 207924136;
    RepairnatorConfig repairnatorConfig = RepairnatorConfig.getInstance();
    repairnatorConfig.setClean(false);
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_checkout");
    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.getGitHelper()).thenReturn(new GitHelper());
    JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    CheckoutBuggyBuild checkoutBuggyBuild = new CheckoutBuggyBuild(inspector);
    cloneStep.setNextStep(checkoutBuggyBuild);
    cloneStep.execute();
    assertThat(checkoutBuggyBuild.getPipelineState(), is(PipelineState.BUILDCHECKEDOUT));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.BUILDCHECKEDOUT));
    assertThat(checkoutBuggyBuild.isShouldStop(), is(false));
    Git gitDir = Git.open(new File(tmpDir, "repo"));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    boolean foundRightCommitAfterRepairCommits = false;
    boolean stopSearch = false;
    while (iterator.hasNext() && !stopSearch) {
        RevCommit revCommit = iterator.next();
        if (revCommit.getName().equals(build.getCommit().getSha())) {
            foundRightCommitAfterRepairCommits = true;
            stopSearch = true;
        } else if (!revCommit.getShortMessage().contains("repairnator")) {
            stopSearch = true;
        }
    }
    assertThat(foundRightCommitAfterRepairCommits, is(true));
}
Also used : Path(java.nio.file.Path) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) 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) CloneRepository(fr.inria.spirals.repairnator.process.step.CloneRepository) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 42 with JobStatus

use of fr.inria.spirals.repairnator.process.inspectors.JobStatus in project repairnator by Spirals-Team.

the class TestAbstractStep method testGetPomWithComplexMavenProjectShouldSetRepoPath.

@Test
public void testGetPomWithComplexMavenProjectShouldSetRepoPath() {
    ProjectInspector mockInspector = mock(ProjectInspector.class);
    String localRepoPath = "./src/test/resources/test-abstractstep/complex-maven-project";
    when(mockInspector.getRepoLocalPath()).thenReturn(localRepoPath);
    JobStatus jobStatus = new JobStatus(localRepoPath);
    when(mockInspector.getJobStatus()).thenReturn(jobStatus);
    AbstractStep step1 = new AbstractStepNop(mockInspector);
    String expectedPomPath = localRepoPath + "/a-submodule";
    String obtainedPom = step1.getPom();
    assertThat(jobStatus.getPomDirPath(), is(expectedPomPath));
}
Also used : JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) Test(org.junit.Test)

Example 43 with JobStatus

use of fr.inria.spirals.repairnator.process.inspectors.JobStatus in project repairnator by Spirals-Team.

the class TestAbstractStep method testSetStateWillGiveStateToOtherSteps.

@Test
public void testSetStateWillGiveStateToOtherSteps() {
    ProjectInspector mockInspector = mock(ProjectInspector.class);
    JobStatus jobStatus = new JobStatus("");
    when(mockInspector.getJobStatus()).thenReturn(jobStatus);
    AbstractStep step1 = new AbstractStepNop(mockInspector);
    AbstractStep step2 = new AbstractStepNop(mockInspector);
    AbstractStep step3 = new AbstractStepNop(mockInspector);
    PipelineState state = PipelineState.NOTFAILING;
    step1.setNextStep(step2).setNextStep(step3);
    step1.setPipelineState(state);
    assertThat(step3.getPipelineState(), is(state));
}
Also used : JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) PipelineState(fr.inria.spirals.repairnator.states.PipelineState) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) Test(org.junit.Test)

Example 44 with JobStatus

use of fr.inria.spirals.repairnator.process.inspectors.JobStatus in project repairnator by Spirals-Team.

the class TestAbstractStep method testGetPomOnSimpleProject.

@Test
public void testGetPomOnSimpleProject() {
    ProjectInspector mockInspector = mock(ProjectInspector.class);
    String localRepoPath = "./src/test/resources/test-abstractstep/simple-maven-project";
    when(mockInspector.getRepoLocalPath()).thenReturn(localRepoPath);
    JobStatus jobStatus = new JobStatus(localRepoPath);
    when(mockInspector.getJobStatus()).thenReturn(jobStatus);
    AbstractStep step1 = new AbstractStepNop(mockInspector);
    String expectedPomPath = localRepoPath + "/pom.xml";
    assertThat(step1.getPom(), is(expectedPomPath));
}
Also used : JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) Test(org.junit.Test)

Example 45 with JobStatus

use of fr.inria.spirals.repairnator.process.inspectors.JobStatus 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

JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)48 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)39 Test (org.junit.Test)38 Build (fr.inria.jtravis.entities.Build)37 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)35 File (java.io.File)34 Path (java.nio.file.Path)33 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)30 CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)22 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)10 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)8 Git (org.eclipse.jgit.api.Git)7 RevCommit (org.eclipse.jgit.revwalk.RevCommit)6 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)5 ArrayList (java.util.ArrayList)5 JsonObject (com.google.gson.JsonObject)4 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)4 BuildShouldFail (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail)4 Date (java.util.Date)4 ScannedBuildStatus (fr.inria.spirals.repairnator.states.ScannedBuildStatus)3