use of de.dagere.peass.analysis.all.RepoFolders in project peass by DaGeRe.
the class ClassifyByRules method classifyProject.
private void classifyProject(final Set<String> allFeatures, final String project) throws IOException, JsonParseException, JsonMappingException {
final RepoFolders repos = new RepoFolders();
final File learnFile = new File(repos.getClassificationFolder(), project + ".json");
final File learnPropertyFile = repos.getProjectPropertyFile(project);
final Classification learn = Constants.OBJECTMAPPER.readValue(learnFile, Classification.class);
final VersionChangeProperties changes = Constants.OBJECTMAPPER.readValue(learnPropertyFile, VersionChangeProperties.class);
final File methodFileFolder = new File(learnPropertyFile.getParentFile(), "methods");
try (BufferedWriter csvWriter = new BufferedWriter(new FileWriter(new File(project + ".csv")))) {
for (final Entry<String, ChangeProperties> version : changes.getVersions().entrySet()) {
final File versionFolder = new File(methodFileFolder, version.getKey());
for (final Entry<String, List<ChangeProperty>> testcase : version.getValue().getProperties().entrySet()) {
for (final ChangeProperty property : testcase.getValue()) {
final VersionClass versionClass = learn.getVersions().get(version.getKey());
final ChangedEntity entity = new ChangedEntity(testcase.getKey(), "", property.getMethod());
final TestcaseClass testcaseClass = versionClass.getTestcases().get(entity);
final GuessDecider guesser = new GuessDecider(versionFolder);
final Set<String> types = testcaseClass.getTypes();
writeFeatures(allFeatures, csvWriter, property, guesser);
writeType(csvWriter, types);
csvWriter.write("\n");
csvWriter.flush();
}
}
}
}
}
use of de.dagere.peass.analysis.all.RepoFolders in project peass by DaGeRe.
the class ClassifyByRules method getAllFeatures.
private Set<String> getAllFeatures() throws IOException, JsonParseException, JsonMappingException {
final Set<String> allFeatures = new HashSet<>();
for (final String project : new String[] { learnproject, classifyproject }) {
final RepoFolders repos = new RepoFolders();
final File learnFile = new File(repos.getClassificationFolder(), project + ".json");
final File learnPropertyFile = repos.getProjectPropertyFile(project);
final Classification learn = Constants.OBJECTMAPPER.readValue(learnFile, Classification.class);
final VersionChangeProperties changes = Constants.OBJECTMAPPER.readValue(learnPropertyFile, VersionChangeProperties.class);
final File methodFileFolder = new File(learnPropertyFile.getParentFile(), "methods");
getAllWords(learn, changes, methodFileFolder, allFeatures);
}
return allFeatures;
}
use of de.dagere.peass.analysis.all.RepoFolders in project peass by DaGeRe.
the class ExperimentSelector method call.
@Override
public Integer call() throws Exception {
if (propertyFile == null) {
final RepoFolders repoFolders = new RepoFolders();
final File propertiesFolder = new File(repoFolders.getPropertiesFolder(), "properties");
for (final File projectFile : propertiesFolder.listFiles()) {
LOG.info("Searching in {}", projectFile);
final File currentPropertyFile = projectFile.listFiles((FilenameFilter) new WildcardFileFilter("*.json"))[0];
selectForProject(currentPropertyFile, null);
}
} else {
selectForProject(propertyFile, changesFile);
}
return 0;
}
use of de.dagere.peass.analysis.all.RepoFolders in project peass by DaGeRe.
the class ExperimentSelector method selectForProject.
private void selectForProject(final File currentPropertyFile, final File currentChangeFile) throws IOException, JsonParseException, JsonMappingException, FileNotFoundException {
final RepoFolders repoFolders = new RepoFolders();
final VersionChangeProperties properties = Constants.OBJECTMAPPER.readValue(currentPropertyFile, VersionChangeProperties.class);
final ProjectChanges changes;
if (currentChangeFile != null && currentChangeFile.exists()) {
changes = Constants.OBJECTMAPPER.readValue(currentChangeFile, ProjectChanges.class);
} else {
changes = null;
}
final String projectName = currentChangeFile != null ? currentChangeFile.getName().replace(".json", "") : currentPropertyFile.getParentFile().getName();
final File fileSlurm = new File(repoFolders.getRCAScriptFolder(), "rca-slurm-" + projectName + ".sh");
final File fileJava = new File(repoFolders.getRCAScriptFolder(), "rca-java-" + projectName + ".sh");
final ExecutionData executionData = repoFolders.getExecutionData(projectName);
final RunCommandWriter writerSlurm = new RunCommandWriterSlurm(new PrintStream(fileSlurm), "cause1", executionData, RunCommandWriterSlurm.EXECUTE_RCA);
final RunCommandWriter writer = new RunCommandWriterRCA(new PrintStream(fileJava), "cause1", executionData);
properties.executeProcessor((version, testcase, change, changeProperties) -> {
all++;
});
if (changes != null) {
changes.executeProcessor((version, testcase, change) -> {
measurementAll++;
});
} else {
printOnlyChanged = false;
}
writeExecutions(properties, changes, writerSlurm, writer);
System.out.println("All: " + executionData.getAllExecutions());
System.out.println("All: " + all + " No testchange: " + noTestchange + " Measurement change: " + measurementChange + " All: " + measurementAll);
}
use of de.dagere.peass.analysis.all.RepoFolders 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;
}
Aggregations