Search in sources :

Example 26 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class Launcher method getBuildToBeInspected.

private void getBuildToBeInspected() {
    Build buggyBuild = BuildHelper.getBuildFromId(this.config.getBuildId(), null);
    if (buggyBuild.getFinishedAt() == null) {
        LOGGER.error("Apparently the buggy build is not yet finished (maybe it has been restarted?). The process will exit now.");
        System.exit(-1);
    }
    String runId = this.config.getRunId();
    if (this.config.getLauncherMode() == LauncherMode.BEARS) {
        Build patchedBuild = BuildHelper.getBuildFromId(this.config.getNextBuildId(), null);
        if (patchedBuild != null) {
            LOGGER.info("The patched build (" + patchedBuild.getId() + ") was successfully retrieved from Travis.");
        } else {
            LOGGER.error("Error while getting patched build: obtained null value. The process will exit now.");
            System.exit(-1);
        }
        if (buggyBuild.getBuildStatus() == BuildStatus.FAILED) {
            this.buildToBeInspected = new BuildToBeInspected(buggyBuild, patchedBuild, ScannedBuildStatus.FAILING_AND_PASSING, runId);
        } else {
            this.buildToBeInspected = new BuildToBeInspected(buggyBuild, patchedBuild, ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES, runId);
        }
    } else {
        Build nextPassing = BuildHelper.getNextBuildOfSameBranchOfStatusAfterBuild(buggyBuild, BuildStatus.PASSED);
        if (nextPassing != null) {
            this.buildToBeInspected = new BuildToBeInspected(buggyBuild, nextPassing, ScannedBuildStatus.FAILING_AND_PASSING, runId);
        } else {
            this.buildToBeInspected = new BuildToBeInspected(buggyBuild, null, ScannedBuildStatus.ONLY_FAIL, runId);
        }
        // switch off push mechanism in case of test project
        // and switch off serialization
        String project = buggyBuild.getRepository().getSlug().toLowerCase();
        if (this.getListOfProjectsToIgnore().contains(project)) {
            this.config.setPush(false);
            this.engines.clear();
            LOGGER.info("The build " + this.config.getBuildId() + " is from a project to be ignored (" + project + "), thus the pipeline deactivated serialization for that build.");
        }
    }
}
Also used : Build(fr.inria.jtravis.entities.Build)

Example 27 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class TestCloneRepositoryStep method testCloneBuildWithSubmodule.

@Test
public void testCloneBuildWithSubmodule() throws IOException {
    // surli/failingProject build
    int buildId = 355839305;
    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));
    File licenceInSubmodule = new File(tmpDirPath.toFile(), "repo/grakn-spec/LICENSE");
    assertThat("Submodule are not supported", licenceInSubmodule.exists(), is(true));
}
Also used : Path(java.nio.file.Path) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) 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 28 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class TestComputeClasspath method testComputeClasspath.

@Test
public void testComputeClasspath() 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_computecp");
    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);
    ComputeClasspath computeClasspath = new ComputeClasspath(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(computeClasspath);
    cloneStep.execute();
    assertThat(computeClasspath.shouldStop, is(false));
    assertThat(computeClasspath.getPipelineState(), is(PipelineState.CLASSPATHCOMPUTED));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.CLASSPATHCOMPUTED));
    List<URL> expectedClasspath = new ArrayList<URL>();
    URL classDir = new URL("file:" + repoDir.getAbsolutePath() + "/target/classes/");
    URL testDir = new URL("file:" + repoDir.getAbsolutePath() + "/target/test-classes/");
    URL junit = new URL("file:" + tmpDir.getAbsolutePath() + "/.m2/junit/junit/4.11/junit-4.11.jar");
    URL hamcrest = new URL("file:" + tmpDir.getAbsolutePath() + "/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar");
    expectedClasspath.add(classDir);
    expectedClasspath.add(testDir);
    expectedClasspath.add(junit);
    expectedClasspath.add(hamcrest);
    assertThat(jobStatus.getRepairClassPath(), is(expectedClasspath));
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ArrayList(java.util.ArrayList) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) URL(java.net.URL) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) File(java.io.File) Test(org.junit.Test)

Example 29 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class TestComputeSourceDir method testComputeSourceDir.

@Test
public void testComputeSourceDir() 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_computesourcedir");
    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(new TestProject(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() + "/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 30 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class TestComputeSourceDir method testComputeSourceDirWithMultiModuleProject.

@Test
public void testComputeSourceDirWithMultiModuleProject() 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() + "/test-projects");
    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() + "/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

Build (fr.inria.jtravis.entities.Build)60 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)44 File (java.io.File)41 Path (java.nio.file.Path)40 Test (org.junit.Test)40 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)37 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)33 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)31 CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)28 ArrayList (java.util.ArrayList)15 Git (org.eclipse.jgit.api.Git)13 JsonObject (com.google.gson.JsonObject)12 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)12 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)11 Date (java.util.Date)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)11 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)10 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)9 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7