Search in sources :

Example 6 with ProjectInspector

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

the class TestAbstractStep method testGetPomWhenNotFoundShouldSetStopFlag.

@Test
public void testGetPomWhenNotFoundShouldSetStopFlag() {
    ProjectInspector mockInspector = mock(ProjectInspector.class);
    String localRepoPath = "./unkown-path";
    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";
    // return this path but set the flag to stop
    assertThat(step1.getPom(), is(expectedPomPath));
    assertThat(step1.shouldStop, is(true));
}
Also used : JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) Test(org.junit.Test)

Example 7 with ProjectInspector

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

the class TestBuildProject method testBuildProject.

@Test
public void testBuildProject() throws IOException {
    // surli/failingProject build
    int buildId = 207924136;
    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 = 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);
    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) 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 8 with ProjectInspector

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

the class TestCloneRepositoryStep method testCloneMasterBuild.

@Test
public void testCloneMasterBuild() throws IOException {
    // surli/failingProject build
    int buildId = 207924136;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_clone");
    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);
    cloneStep.execute();
    assertThat(jobStatus.getPipelineState(), is(PipelineState.CLONABLE));
    assertThat(cloneStep.getPipelineState(), is(PipelineState.CLONABLE));
    assertThat(cloneStep.shouldStop, is(false));
    Git gitDir = Git.open(new File(tmpDir, "repo"));
    Ref ref = gitDir.getRepository().exactRef("HEAD");
    assertThat(ref.isSymbolic(), is(true));
    ref = ref.getTarget();
    // no check out yet
    assertThat(ref.getObjectId().getName(), not(build.getCommit().getSha()));
}
Also used : Path(java.nio.file.Path) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) Ref(org.eclipse.jgit.lib.Ref) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) 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 9 with ProjectInspector

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

the class TestComputeSourceDir method testComputeSourceDirWithMultiModuleProject4.

@Test
public void testComputeSourceDirWithMultiModuleProject4() throws IOException {
    // pac4j/pac4j
    int buildId = 216674182;
    int patchedBuildId = 218753299;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Build patchedBuild = BuildHelper.getBuildFromId(patchedBuildId, null);
    assertThat(patchedBuild, notNullValue());
    assertThat(patchedBuildId, is(patchedBuild.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_computesourcedir3");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    File repoDir = new File(tmpDir, "repo");
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, patchedBuild, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, "");
    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.getPatchedBuild()).thenReturn(patchedBuild);
    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);
    ComputeSourceDir computeSourceDir = new ComputeSourceDir(inspector, false);
    cloneStep.setNextStep(new CheckoutPatchedBuild(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() + "/pac4j-core/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-config/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-oauth/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-cas/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-openid/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-http/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-saml/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-gae/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-oidc/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-jwt/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-ldap/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-sql/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-mongo/src/main/java"), new File(repoDir.getAbsolutePath() + "/pac4j-stormpath/src/main/java") }));
}
Also used : Path(java.nio.file.Path) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CheckoutPatchedBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild) 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 10 with ProjectInspector

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

the class TestComputeSourceDir method testComputeSourceDirWithMultiModuleProject3.

@Test
public void testComputeSourceDirWithMultiModuleProject3() 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());
    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"), new File(repoDir.getAbsolutePath() + "/test-projects/src/main/java") }));
}
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)

Aggregations

ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)43 Test (org.junit.Test)40 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)39 File (java.io.File)35 Path (java.nio.file.Path)35 Build (fr.inria.jtravis.entities.Build)33 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)33 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)30 CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)24 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)10 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)8 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)7 Git (org.eclipse.jgit.api.Git)7 BuildShouldFail (fr.inria.spirals.repairnator.process.step.gatherinfo.BuildShouldFail)6 RevCommit (org.eclipse.jgit.revwalk.RevCommit)6 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)4 ScannedBuildStatus (fr.inria.spirals.repairnator.states.ScannedBuildStatus)3 DiffEntry (org.eclipse.jgit.diff.DiffEntry)3 ObjectReader (org.eclipse.jgit.lib.ObjectReader)3 CanonicalTreeParser (org.eclipse.jgit.treewalk.CanonicalTreeParser)3