use of fr.inria.spirals.repairnator.process.maven.MavenHelper in project repairnator by Spirals-Team.
the class TestMavenFilterTestOutputHandler method testFilterLogWillWork.
@Test
public void testFilterLogWillWork() throws IOException {
String resourcePath = "./src/test/resources/build-logs/log-test-failures.txt";
List<String> lines = Files.readAllLines(new File(resourcePath).toPath());
ProjectInspector inspector = mock(ProjectInspector.class);
Path tmp = Files.createTempDirectory("test-filter");
when(inspector.getRepoLocalPath()).thenReturn(tmp.toAbsolutePath().toString());
JobStatus jobStatus = new JobStatus(tmp.toAbsolutePath().toString());
when(inspector.getJobStatus()).thenReturn(jobStatus);
MavenHelper mavenHelper = mock(MavenHelper.class);
when(mavenHelper.getInspector()).thenReturn(inspector);
when(mavenHelper.getName()).thenReturn("test");
MavenFilterTestOutputHandler filterTest = new MavenFilterTestOutputHandler(mavenHelper);
for (String s : lines) {
filterTest.consumeLine(s);
}
assertTrue(filterTest.isFailingWithTest());
assertEquals(40, filterTest.getRunningTests());
assertEquals(0, filterTest.getFailingTests());
assertEquals(9, filterTest.getErroringTests());
assertEquals(3, filterTest.getSkippingTests());
}
use of fr.inria.spirals.repairnator.process.maven.MavenHelper in project repairnator by Spirals-Team.
the class TestMavenFilterTestOutputHandler method testFilterLogWillWork2.
@Test
public void testFilterLogWillWork2() throws IOException {
String resourcePath = "./src/test/resources/build-logs/log-test-druidio.txt";
List<String> lines = Files.readAllLines(new File(resourcePath).toPath());
ProjectInspector inspector = mock(ProjectInspector.class);
Path tmp = Files.createTempDirectory("test-filter");
when(inspector.getRepoLocalPath()).thenReturn(tmp.toAbsolutePath().toString());
JobStatus jobStatus = new JobStatus(tmp.toAbsolutePath().toString());
when(inspector.getJobStatus()).thenReturn(jobStatus);
MavenHelper mavenHelper = mock(MavenHelper.class);
when(mavenHelper.getInspector()).thenReturn(inspector);
when(mavenHelper.getName()).thenReturn("test");
MavenFilterTestOutputHandler filterTest = new MavenFilterTestOutputHandler(mavenHelper);
for (String s : lines) {
filterTest.consumeLine(s);
}
assertFalse(filterTest.isFailingWithTest());
assertEquals(77351 * 2, filterTest.getRunningTests());
assertEquals(0, filterTest.getFailingTests());
assertEquals(0, filterTest.getErroringTests());
assertEquals((52 + 6 + 1) * 2, filterTest.getSkippingTests());
}
use of fr.inria.spirals.repairnator.process.maven.MavenHelper in project repairnator by Spirals-Team.
the class ComputeClasspath method businessExecute.
@Override
protected void businessExecute() {
this.getLogger().debug("Computing classpath from incriminated module...");
String incriminatedModule = this.getInspector().getJobStatus().getFailingModulePath();
File defaultClassDir = new File(incriminatedModule + File.separator + DEFAULT_CLASSES_DIR + File.separator);
this.addFileToClassPath(defaultClassDir);
File defaultTestClassDir = new File(incriminatedModule + File.separator + DEFAULT_TEST_CLASSES_DIR + File.separator);
this.addFileToClassPath(defaultTestClassDir);
Properties properties = new Properties();
properties.setProperty("mdep.outputFile", CLASSPATH_FILENAME);
String goal = "dependency:build-classpath";
String pomModule = incriminatedModule + File.separator + "pom.xml";
MavenHelper helper = new MavenHelper(pomModule, goal, properties, this.getClass().getSimpleName(), this.inspector, true);
int result = MavenHelper.MAVEN_ERROR;
try {
result = helper.run();
} catch (InterruptedException e) {
this.addStepError("Error with maven goal", e);
}
if (result != MavenHelper.MAVEN_SUCCESS) {
this.getLogger().debug("Error while computing classpath maven");
this.setPipelineState(PipelineState.CLASSPATHNOTCOMPUTED);
return;
}
String classpathPath = incriminatedModule + File.separator + CLASSPATH_FILENAME;
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(classpathPath)));
String classpathLine = reader.readLine();
String[] allJars = classpathLine.split(":");
for (String jar : allJars) {
File f = new File(jar);
this.addFileToClassPath(f);
}
} catch (IOException e) {
this.addStepError("Problem while getting classpath: " + e);
this.setPipelineState(PipelineState.CLASSPATHNOTCOMPUTED);
// return ?
}
boolean containJunit = false;
for (URL url : classPath) {
if (url.toString().contains("junit")) {
containJunit = true;
break;
}
}
if (!containJunit) {
this.addStepError("The classpath seems not to contain JUnit, maybe this project does not use junit for testing.");
}
this.inspector.getJobStatus().setRepairClassPath(this.classPath);
this.inspector.getJobStatus().getMetrics().setNbLibraries(this.classPath.size() - 2);
this.setPipelineState(PipelineState.CLASSPATHCOMPUTED);
}
use of fr.inria.spirals.repairnator.process.maven.MavenHelper in project repairnator by Spirals-Team.
the class TestProject method businessExecute.
protected void businessExecute() {
this.getLogger().debug("Launching tests with maven...");
MavenHelper helper = new MavenHelper(this.getPom(), "test", null, this.getClass().getSimpleName(), this.inspector, false);
MavenFilterTestOutputHandler outputTestFilter = new MavenFilterTestOutputHandler(helper);
helper.setOutputHandler(outputTestFilter);
int result = MavenHelper.MAVEN_ERROR;
try {
result = helper.run();
} catch (InterruptedException e) {
this.addStepError("Error while executing maven goal", e);
}
if (result == MavenHelper.MAVEN_SUCCESS) {
if (outputTestFilter.getRunningTests() > 0) {
this.getLogger().debug(outputTestFilter.getRunningTests() + " tests has been launched but none failed.");
} else {
this.addStepError("No test recorded.");
}
this.setPipelineState(PipelineState.NOTFAILING);
} else {
if (outputTestFilter.isFailingWithTest()) {
this.getLogger().debug(outputTestFilter.getFailingTests() + " tests failed, go to next step.");
this.setPipelineState(PipelineState.TESTABLE);
} else {
this.addStepError("Error while testing the project.");
this.setPipelineState(PipelineState.NOTTESTABLE);
this.shouldStop = true;
}
}
}
use of fr.inria.spirals.repairnator.process.maven.MavenHelper in project repairnator by Spirals-Team.
the class BuildProject method businessExecute.
protected void businessExecute() {
this.getLogger().debug("Building project with maven (skip tests)...");
Properties properties = new Properties();
properties.setProperty(MavenHelper.SKIP_TEST_PROPERTY, "true");
this.getLogger().debug("Installing artifacts without test execution...");
MavenHelper helper = new MavenHelper(this.getPom(), "install", properties, this.getClass().getSimpleName(), this.inspector, true);
int result;
try {
result = helper.run();
} catch (InterruptedException e) {
this.addStepError("Error while building", e);
result = MavenHelper.MAVEN_ERROR;
}
if (result == MavenHelper.MAVEN_SUCCESS) {
this.setPipelineState(PipelineState.BUILDABLE);
} else {
this.getLogger().warn("Repository " + this.inspector.getRepoSlug() + " cannot be built.");
this.setPipelineState(PipelineState.NOTBUILDABLE);
this.shouldStop = true;
}
}
Aggregations