use of de.dagere.peass.config.ExecutionConfig in project peass by DaGeRe.
the class ReadProperties method detectVersionProperty.
private int detectVersionProperty(final File projectFolder, final File viewFolder, final BufferedWriter csvWriter, final VersionChangeProperties versionProperties, final Entry<String, Changes> versionChanges, final String predecessor, final ExecutionData data) throws IOException, JsonGenerationException, JsonMappingException {
final File methodFolder = new File(out.getParentFile(), "methods");
methodFolder.mkdirs();
final String version = versionChanges.getKey();
final ChangeProperties changeProperties = new ChangeProperties();
changeProperties.setCommitText(GitUtils.getCommitText(projectFolder, version));
changeProperties.setCommitter(GitUtils.getCommitter(projectFolder, version));
versionProperties.getVersions().put(version, changeProperties);
int count = 0;
for (final Entry<String, List<Change>> changes : versionChanges.getValue().getTestcaseChanges().entrySet()) {
final String testclazz = changes.getKey();
String module = null;
for (TestCase test : data.getVersions().get(versionChanges.getKey()).getTests()) {
if (test.getClazz().equals(testclazz)) {
module = test.getModule();
}
}
final List<ChangeProperty> properties = new LinkedList<>();
changeProperties.getProperties().put(testclazz, properties);
for (final Change testcaseChange : changes.getValue()) {
ExecutionConfig config = new ExecutionConfig();
config.setVersion(version);
config.setVersionOld(predecessor);
ChangedEntity entity = new ChangedEntity(testclazz, module);
final PropertyReadHelper reader = new PropertyReadHelper(config, entity, testcaseChange, projectFolder, viewFolder, methodFolder, null);
final ChangeProperty currentProperty = reader.read();
// if (currentProperty != null) {
properties.add(currentProperty);
Constants.OBJECTMAPPER.writeValue(out, versionProperties);
writeCSVLine(csvWriter, currentProperty, projectFolder.getName());
// }
count++;
}
}
return count;
}
use of de.dagere.peass.config.ExecutionConfig in project peass by DaGeRe.
the class ReadProperties method call.
@Override
public Void call() throws Exception {
final RepoFolders folders = new RepoFolders();
final String projectName = projectFolder.getName();
SelectedTests selectedTests = VersionSorter.getSelectedTests(staticSelectionFile, executionFile, folders.getDependencyFile(projectName));
if (!projectFolder.exists()) {
GitUtils.downloadProject(selectedTests.getUrl(), projectFolder);
}
System.out.println("Read all: " + ReadAllProperties.readAll);
if (ReadAllProperties.readAll) {
final ExecutionData changedTests = executionFile != null ? Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class) : folders.getExecutionData(projectName);
final File resultFile = new File("results" + File.separator + projectName + File.separator + "properties_alltests.json");
out = resultFile;
ResultsFolders resultsFolders = new ResultsFolders(out, projectName);
final PropertyReader reader = new PropertyReader(resultsFolders, projectFolder, changedTests, new ExecutionConfig());
reader.readAllTestsProperties();
} else {
final File changefile;
if (this.changefile != null) {
changefile = this.changefile;
} else {
changefile = folders.getChangeFile(projectName);
}
if (out == null) {
out = folders.getProjectPropertyFile(projectName);
if (!out.getParentFile().exists()) {
out.getParentFile().mkdirs();
}
}
if (!changefile.exists()) {
LOG.error("Changefile {} needs to exist.", changefile);
System.exit(1);
}
if (!viewfolder.exists()) {
LOG.error("ViewFolder {} needs to exist.", viewfolder);
System.exit(1);
}
StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(staticSelectionFile, StaticTestSelection.class);
readChangeProperties(changefile, projectFolder, viewfolder, new ExecutionData(dependencies));
}
return null;
}
use of de.dagere.peass.config.ExecutionConfig in project peass by DaGeRe.
the class PropertyChangeGuesser method getGuesses.
public Set<String> getGuesses(final PeassFolders folders, final Entry<ChangedEntity, ClazzChangeData> changedEntity) throws FileNotFoundException {
final Set<String> guessedTypes = new HashSet<>();
// TODO Here, a real config should be passed; since this is rarely used, we go with the default folders
ClazzFileFinder finder = new ClazzFileFinder(new ExecutionConfig());
final File file = finder.getSourceFile(folders.getProjectFolder(), changedEntity.getKey());
final File fileOld = finder.getSourceFile(folders.getOldSources(), changedEntity.getKey());
if (file != null && fileOld != null && file.exists() && fileOld.exists()) {
final CompilationUnit clazzUnit = JavaParserProvider.parse(file);
final CompilationUnit clazzUnitOld = JavaParserProvider.parse(fileOld);
for (Map.Entry<String, Set<String>> changedClazz : changedEntity.getValue().getChangedMethods().entrySet()) {
// If only method change..
if (changedClazz.getValue() != null) {
for (String method : changedClazz.getValue()) {
final String source = FileComparisonUtil.getMethodSource(changedEntity.getKey(), method, clazzUnit);
final String sourceOld = FileComparisonUtil.getMethodSource(changedEntity.getKey(), method, clazzUnitOld);
final Patch<String> changedLinesMethod = DiffUtils.diff(Arrays.asList(sourceOld.split("\n")), Arrays.asList(source.split("\n")));
for (final Delta<String> delta : changedLinesMethod.getDeltas()) {
getDeltaGuess(guessedTypes, (delta.getOriginal().getLines()));
getDeltaGuess(guessedTypes, (delta.getRevised().getLines()));
}
}
}
}
}
return guessedTypes;
}
use of de.dagere.peass.config.ExecutionConfig in project peass by DaGeRe.
the class TestClazzFileFinder method testClasses.
@Test
public void testClasses() {
ExecutionConfig config = new ExecutionConfig();
config.getClazzFolders().add("src/main/java");
config.getClazzFolders().add("src/java");
List<String> clazzes = new ClazzFileFinder(config).getClasses(SOURCE);
System.out.println(clazzes);
MatcherAssert.assertThat(clazzes, Matchers.hasItem("de.TestMe1"));
MatcherAssert.assertThat(clazzes, Matchers.hasItem("de.TestMe2"));
MatcherAssert.assertThat(clazzes, Matchers.hasItem("de.Second"));
MatcherAssert.assertThat(clazzes, Matchers.hasItem("de.TestMe2$Inner"));
MatcherAssert.assertThat(clazzes, Matchers.hasItem("de.TestMe2$Inner$InnerInner"));
MatcherAssert.assertThat(clazzes, Matchers.hasItem("de.TestMe2$InnerEnum"));
}
use of de.dagere.peass.config.ExecutionConfig in project peass by DaGeRe.
the class TestPeassFilter method testExecution.
@Test
public void testExecution() throws ViewNotFoundException, IOException, XmlPullParserException, InterruptedException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
Assume.assumeFalse(EnvironmentVariables.isWindows());
PeassFolders folders = new PeassFolders(CURRENT);
final KiekerResultManager manager = new KiekerResultManager(folders, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
final TestSet testset = new TestSet();
final TestCase testcase = new TestCase("defaultpackage.TestMe", "testMe", "");
testset.addTest(testcase);
final ModuleClassMapping mapping = new ModuleClassMapping(manager.getExecutor());
final List<TraceElement> referenceTrace = regenerateTrace(manager, testset, testcase, mapping, 0);
for (int i = 1; i <= 3; i++) {
final List<TraceElement> compareTrace = regenerateTrace(manager, testset, testcase, mapping, i);
checkRegeneratedTrace(referenceTrace, compareTrace);
}
}
Aggregations