use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.
the class TestComputeSourceDir method testComputeSourceDirWithMultiModuleProject5.
@Test
public void testComputeSourceDirWithMultiModuleProject5() throws IOException {
// Spirals-Team/librepair build
int buildId = 218168470;
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")}));
}
use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.
the class TestComputeSourceDir method testComputeSourceDirWithMultiModuleProject2.
@Test
public void testComputeSourceDirWithMultiModuleProject2() 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() + "/a-module");
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") }));
}
use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.
the class TestGatherTestInformation method testGatherTestInformationWhenNotFailing.
@Test
public void testGatherTestInformationWhenNotFailing() 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);
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");
when(inspector.getJobStatus()).thenReturn(jobStatus);
CloneRepository cloneStep = new CloneRepository(inspector);
GatherTestInformation gatherTestInformation = new GatherTestInformation(inspector, new BuildShouldFail(), false);
cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(gatherTestInformation);
cloneStep.execute();
assertThat(gatherTestInformation.shouldStop, is(true));
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));
}
use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.
the class TestGatherTestInformation method testGatherTestInformationOnlyOneErroring.
@Test
public void testGatherTestInformationOnlyOneErroring() throws IOException {
// surli/failingProject build
int buildId = 208897371;
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);
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");
when(inspector.getJobStatus()).thenReturn(jobStatus);
CloneRepository cloneStep = new CloneRepository(inspector);
GatherTestInformation gatherTestInformation = new GatherTestInformation(inspector, new BuildShouldFail(), false);
cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(gatherTestInformation);
cloneStep.execute();
assertThat(gatherTestInformation.shouldStop, is(false));
assertThat(gatherTestInformation.getPipelineState(), is(PipelineState.HASTESTERRORS));
assertThat(jobStatus.getPipelineState(), is(PipelineState.HASTESTERRORS));
assertThat(jobStatus.getFailingModulePath(), is(repoDir.getCanonicalPath()));
assertThat(gatherTestInformation.getNbTotalTests(), is(8));
assertThat(gatherTestInformation.getNbFailingTests(), is(0));
assertThat(gatherTestInformation.getNbErroringTests(), is(1));
assertThat(gatherTestInformation.getNbSkippingTests(), is(0));
Set<String> failureNames = jobStatus.getMetrics().getFailureNames();
assertThat("failure names" + StringUtils.join(failureNames.toArray()), failureNames.contains("java.lang.StringIndexOutOfBoundsException"), is(true));
assertThat(failureNames.size(), is(1));
assertThat(jobStatus.getFailureLocations().size(), is(1));
FailureLocation expectedFailureLocation = new FailureLocation("nopol_examples.nopol_example_1.NopolExampleTest");
FailureType failureType = new FailureType("java.lang.StringIndexOutOfBoundsException", "String index out of range: -5", true);
expectedFailureLocation.addFailure(failureType);
expectedFailureLocation.addErroringMethod("nopol_examples.nopol_example_1.NopolExampleTest#test5");
FailureLocation actualLocation = jobStatus.getFailureLocations().iterator().next();
assertThat(actualLocation, is(expectedFailureLocation));
}
use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.
the class TestGatherTestInformation method testGatherTestInformationWhenErroring.
@Test
public void testGatherTestInformationWhenErroring() throws IOException {
// surli/failingProject build
int buildId = 208240908;
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);
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");
when(inspector.getJobStatus()).thenReturn(jobStatus);
CloneRepository cloneStep = new CloneRepository(inspector);
GatherTestInformation gatherTestInformation = new GatherTestInformation(inspector, new BuildShouldFail(), false);
cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new TestProject(inspector)).setNextStep(gatherTestInformation);
cloneStep.execute();
assertThat(gatherTestInformation.shouldStop, is(false));
assertThat(gatherTestInformation.getPipelineState(), is(PipelineState.HASTESTERRORS));
assertThat(jobStatus.getPipelineState(), is(PipelineState.HASTESTERRORS));
assertThat(jobStatus.getFailingModulePath(), is(repoDir.getCanonicalPath()));
assertThat(gatherTestInformation.getNbTotalTests(), is(26));
assertThat(gatherTestInformation.getNbFailingTests(), is(0));
assertThat(gatherTestInformation.getNbErroringTests(), is(5));
assertThat(gatherTestInformation.getNbSkippingTests(), is(0));
Set<String> failureNames = jobStatus.getMetrics().getFailureNames();
assertThat("Got the following errors: " + StringUtils.join(failureNames, ","), failureNames.contains("java.lang.NullPointerException"), is(true));
assertThat(failureNames.size(), is(3));
assertThat(jobStatus.getFailureLocations().size(), is(4));
}
Aggregations