Search in sources :

Example 1 with ChangeReader

use of de.dagere.peass.analysis.changes.ChangeReader in project peass by DaGeRe.

the class GetChanges method createReader.

private ChangeReader createReader(final ResultsFolders resultsFolders, final SelectedTests selectedTests) throws FileNotFoundException {
    RunCommandWriterRCA runCommandWriter = null;
    RunCommandWriterSlurmRCA runCommandWriterSlurm = null;
    if (selectedTests.getUrl() != null && !selectedTests.getUrl().isEmpty()) {
        final PrintStream runCommandPrinter = new PrintStream(new File(resultsFolders.getStatisticsFile().getParentFile(), "run-rca-" + selectedTests.getName() + ".sh"));
        runCommandWriter = new RunCommandWriterRCA(runCommandPrinter, "default", selectedTests);
        final PrintStream runCommandPrinterRCA = new PrintStream(new File(resultsFolders.getStatisticsFile().getParentFile(), "run-rca-slurm-" + selectedTests.getName() + ".sh"));
        runCommandWriterSlurm = new RunCommandWriterSlurmRCA(runCommandPrinterRCA, "default", selectedTests);
    }
    final ChangeReader reader = new ChangeReader(resultsFolders, runCommandWriter, runCommandWriterSlurm, selectedTests);
    reader.setConfig(statisticConfigMixin.getStasticsConfig());
    return reader;
}
Also used : PrintStream(java.io.PrintStream) RunCommandWriterSlurmRCA(de.dagere.peass.measurement.utils.RunCommandWriterSlurmRCA) ChangeReader(de.dagere.peass.analysis.changes.ChangeReader) RunCommandWriterRCA(de.dagere.peass.measurement.utils.RunCommandWriterRCA) File(java.io.File)

Example 2 with ChangeReader

use of de.dagere.peass.analysis.changes.ChangeReader in project peass by DaGeRe.

the class TestChangeReader method testBasicUsage.

@Test
public void testBasicUsage() throws JAXBException, JsonProcessingException {
    ChangeReader reader = new ChangeReader("android-example-correct", new ExecutionData());
    ProjectChanges changes = reader.readFile(TestAnalyseFullData.REGULAR_DATA_FOLDER.getParentFile());
    System.out.println(Constants.OBJECTMAPPER.writeValueAsString(changes));
    List<Change> methodChanges = changes.getVersionChanges().get("946e4318267b56838aa35da0a2a4e5c0528bfe04").getTestcaseChanges().get("com.example.android_example.ExampleUnitTest");
    Assert.assertEquals(1, methodChanges.size());
    Assert.assertEquals("test_TestMe", methodChanges.get(0).getMethod());
    Assert.assertEquals(15087.66, methodChanges.get(0).getOldTime(), 0.1);
}
Also used : ProjectChanges(de.dagere.peass.analysis.changes.ProjectChanges) ChangeReader(de.dagere.peass.analysis.changes.ChangeReader) Change(de.dagere.peass.analysis.changes.Change) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) Test(org.junit.jupiter.api.Test)

Example 3 with ChangeReader

use of de.dagere.peass.analysis.changes.ChangeReader in project peass by DaGeRe.

the class GetChanges method call.

@Override
public Void call() throws Exception {
    SelectedTests selectedTests = VersionSorter.getSelectedTests(staticSelectionFile, executionFile);
    if (!out.exists()) {
        out.mkdirs();
    }
    LOG.info("Errors: 1: {} 2: {}", statisticConfigMixin.getType1error(), statisticConfigMixin.getType2error());
    ResultsFolders folders = new ResultsFolders(out, "out");
    final ChangeReader reader = createReader(folders, selectedTests);
    if (staticSelectionFile != null) {
        StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(staticSelectionFile, StaticTestSelection.class);
        reader.setTests(dependencies.toExecutionData().getVersions());
    }
    if (executionFile != null) {
        ExecutionData executions = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
        reader.setTests(executions.getVersions());
    }
    for (final File dataFile : data) {
        reader.readFile(dataFile);
    }
    return null;
}
Also used : ChangeReader(de.dagere.peass.analysis.changes.ChangeReader) SelectedTests(de.dagere.peass.dependency.persistence.SelectedTests) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 4 with ChangeReader

use of de.dagere.peass.analysis.changes.ChangeReader in project peass by DaGeRe.

the class GetAllChanges method getChangesForMeasurementfolder.

public static void getChangesForMeasurementfolder(final RepoFolders folders, final String project, final File cleanFolder, final StaticTestSelection dependencies) throws JAXBException, FileNotFoundException {
    ResultsFolders resultsFolders = new ResultsFolders(folders.getProjectStatisticsFolder(project), project);
    final ChangeReader reader = new ChangeReader(resultsFolders, project, dependencies);
    final ProjectChanges changes = reader.readFile(cleanFolder);
    if (changes != null) {
        final File allPropertyFile = new File(folders.getPropertiesFolder(), project + File.separator + "properties_alltests.json");
        if (allPropertyFile.exists()) {
            final VersionChangeProperties properties = ReadProperties.readVersionProperties(changes, allPropertyFile);
            try {
                // final ProjectChanges oldKnowledge = ProjectChanges.getOldChanges();
                // ProjectChanges.mergeKnowledge(oldKnowledge, knowledge);
                // ReadProperties.writeOnlySource(properties, oldKnowledge);
                Constants.OBJECTMAPPER.writeValue(folders.getProjectPropertyFile(project), properties);
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : ProjectChanges(de.dagere.peass.analysis.changes.ProjectChanges) ChangeReader(de.dagere.peass.analysis.changes.ChangeReader) IOException(java.io.IOException) ResultsFolders(de.dagere.peass.folders.ResultsFolders) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) File(java.io.File)

Example 5 with ChangeReader

use of de.dagere.peass.analysis.changes.ChangeReader in project peass by DaGeRe.

the class MissingExecutionFinder method removeSlurmExecutions.

private void removeSlurmExecutions(final File folder) throws JAXBException {
    ChangeReader reader = new ChangeReader(folder.getName(), tests);
    reader.readFile(folder);
    for (Entry<String, TestcaseData> entry : reader.getAllData().getData().entrySet()) {
        String version = entry.getKey();
        TestSet versionsTests = tests.getVersions().get(version);
        LOG.debug("Removing from: {}", version);
        for (TestCase test : entry.getValue().getTestcaseData().keySet()) {
            removeTestFromTestSet(test.getClazz(), test.getMethod(), versionsTests);
        }
    }
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ChangeReader(de.dagere.peass.analysis.changes.ChangeReader) TestcaseData(de.dagere.peass.analysis.helper.read.TestcaseData) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Aggregations

ChangeReader (de.dagere.peass.analysis.changes.ChangeReader)6 ProjectChanges (de.dagere.peass.analysis.changes.ProjectChanges)3 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)3 File (java.io.File)3 Change (de.dagere.peass.analysis.changes.Change)2 ResultsFolders (de.dagere.peass.folders.ResultsFolders)2 Test (org.junit.jupiter.api.Test)2 TestcaseData (de.dagere.peass.analysis.helper.read.TestcaseData)1 VersionChangeProperties (de.dagere.peass.analysis.properties.VersionChangeProperties)1 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)1 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)1 SelectedTests (de.dagere.peass.dependency.persistence.SelectedTests)1 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)1 RunCommandWriterRCA (de.dagere.peass.measurement.utils.RunCommandWriterRCA)1 RunCommandWriterSlurmRCA (de.dagere.peass.measurement.utils.RunCommandWriterSlurmRCA)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1