Search in sources :

Example 1 with ResultsFolders

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;
}
Also used : SelectedTests(de.dagere.peass.dependency.persistence.SelectedTests) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) ResultsFolders(de.dagere.peass.folders.ResultsFolders) PropertyReader(de.dagere.peass.analysis.properties.PropertyReader) File(java.io.File) RepoFolders(de.dagere.peass.analysis.all.RepoFolders) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Example 2 with ResultsFolders

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);
}
Also used : ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) Test(org.junit.jupiter.api.Test)

Example 3 with ResultsFolders

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);
}
Also used : FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) HashMap(java.util.HashMap) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) ChangeManager(de.dagere.peass.dependency.ChangeManager) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ResultsFolders(de.dagere.peass.folders.ResultsFolders) KiekerConfig(de.dagere.peass.config.KiekerConfig) Test(org.junit.jupiter.api.Test)

Example 4 with ResultsFolders

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());
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with ResultsFolders

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()));
}
Also used : ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File)

Aggregations

ResultsFolders (de.dagere.peass.folders.ResultsFolders)17 File (java.io.File)16 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)8 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)7 PeassFolders (de.dagere.peass.folders.PeassFolders)7 Test (org.junit.jupiter.api.Test)7 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)6 KiekerConfig (de.dagere.peass.config.KiekerConfig)5 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)5 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)5 TestSelectionConfig (de.dagere.peass.config.TestSelectionConfig)4 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)4 PropertyReader (de.dagere.peass.analysis.properties.PropertyReader)3 VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)3 GitUtils (de.dagere.peass.vcs.GitUtils)3 ChangeReader (de.dagere.peass.analysis.changes.ChangeReader)2 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)2 SelectedTests (de.dagere.peass.dependency.persistence.SelectedTests)2 ReadProperties (de.dagere.peass.ReadProperties)1 RepoFolders (de.dagere.peass.analysis.all.RepoFolders)1