Search in sources :

Example 11 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected 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 12 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected 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)

Example 13 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected in project repairnator by Spirals-Team.

the class TestComputeSourceDir method testComputeSourceDirWithReflexiveReferences.

@Test
public void testComputeSourceDirWithReflexiveReferences() throws IOException {
    int buildId = 345990212;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_computesourcedirOverflow");
    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.SOURCEDIRNOTCOMPUTED));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.SOURCEDIRNOTCOMPUTED));
}
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 14 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected 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 15 with BuildToBeInspected

use of fr.inria.spirals.repairnator.BuildToBeInspected 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)

Aggregations

BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)48 Build (fr.inria.jtravis.entities.Build)44 File (java.io.File)40 Path (java.nio.file.Path)40 Test (org.junit.Test)40 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)35 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)33 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)30 CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)24 Git (org.eclipse.jgit.api.Git)12 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)11 ArrayList (java.util.ArrayList)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)11 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)10 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)8 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)8 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)8 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7