use of de.dagere.peass.folders.ResultsFolders 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.folders.ResultsFolders in project peass by DaGeRe.
the class TestExecutionMerging method mergeWrittenExecutions.
@Test
public void mergeWrittenExecutions() throws JsonGenerationException, JsonMappingException, IOException {
ResultsFolders[] folders = new ResultsFolders[3];
for (int i = 0; i < 3; i++) {
ExecutionData ex1 = createExecutionData(i);
Constants.OBJECTMAPPER.writeValue(new File("target/execute-" + i + ".json"), ex1);
folders[i] = Mockito.mock(ResultsFolders.class);
Mockito.when(folders[i].getTraceTestSelectionFile()).thenReturn(new File("target/execute-" + i + ".json"));
}
ResultsFolders out = new ResultsFolders(new File("target"), "mytest");
ExecutionData merged = PartialDependenciesMerger.mergeExecutions(out, folders);
checkMergedResult(merged);
}
use of de.dagere.peass.folders.ResultsFolders in project peass by DaGeRe.
the class TestGenerateDependencies method testGenerateDependencies.
@Test
public void testGenerateDependencies() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
final FakeFileIterator iterator = new FakeFileIterator(TestConstants.CURRENT_FOLDER, Arrays.asList(TraceGettingIT.REPETITION));
ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, VersionKeeper.INSTANCE, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
final boolean success = reader.readInitialVersion();
Assert.assertTrue(success);
iterator.goToNextCommit();
final ChangeManager manager = Mockito.mock(ChangeManager.class);
final HashMap<ChangedEntity, ClazzChangeData> value = new HashMap<>();
ChangedEntity testMeEntity = new ChangedEntity("viewtest.TestMe", "");
value.put(testMeEntity, new ClazzChangeData(testMeEntity, false));
Mockito.when(manager.getChanges(Mockito.any())).thenReturn(value);
final int tests = reader.analyseVersion(manager);
LOG.debug(Constants.OBJECTMAPPER.writeValueAsString(reader.getDependencies()));
Assert.assertEquals(1, tests);
}
use of de.dagere.peass.folders.ResultsFolders in project peass by DaGeRe.
the class TraceWriterTest method testModuleWriting.
@Test
public void testModuleWriting() throws IOException {
ResultsFolders resultsFolders = new ResultsFolders(tempDir, "test");
TraceWriter writer = new TraceWriter("000001", new TestCase("ClazzA", "methodA", "moduleA"), resultsFolders, new TraceFileMapping());
TraceWithMethods exampleTrace = getTrace();
writer.writeTrace("000002", 3, Mockito.mock(TraceMethodReader.class), exampleTrace);
File expectedResultFile = new File(resultsFolders.getViewFolder(), "view_000001/moduleA§ClazzA/methodA/000002_method");
Assert.assertTrue(expectedResultFile.exists());
}
use of de.dagere.peass.folders.ResultsFolders in project peass by DaGeRe.
the class TraceGeneratorStarter method writeTrace.
private void writeTrace(final String newestVersion, final TestCase testcase, final List<TraceElement> shortTrace) throws IOException {
ResultsFolders results = new ResultsFolders(new File("results"), projectFolder.getName());
String shortVersion = TraceWriter.getShortVersion(newestVersion);
File methodDir = results.getViewMethodDir(newestVersion, testcase);
final File methodExpandedTrace = new File(methodDir, shortVersion + OneTraceGenerator.METHOD_EXPANDED);
Files.write(methodExpandedTrace.toPath(), shortTrace.stream().map(value -> value.toString()).collect(Collectors.toList()));
}
Aggregations