Search in sources :

Example 1 with VersionKeeper

use of de.dagere.peass.dependency.reader.VersionKeeper in project peass by DaGeRe.

the class ContinuousDependencyReader method doPartialRCS.

private void doPartialRCS(final StaticTestSelection dependencies, final VersionIterator newIterator) {
    DependencyReader reader = new DependencyReader(dependencyConfig, folders, resultsFolders, dependencies.getUrl(), newIterator, new VersionKeeper(new File(resultsFolders.getStaticTestSelectionFile().getParentFile(), "nochanges.json")), executionConfig, kiekerConfig, env);
    newIterator.goTo0thCommit();
    reader.readCompletedVersions(dependencies);
    try {
        ExecutionData executions = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
        reader.setExecutionData(executions);
        if (resultsFolders.getCoverageSelectionFile().exists()) {
            ExecutionData coverageExecutions = Constants.OBJECTMAPPER.readValue(resultsFolders.getCoverageSelectionFile(), ExecutionData.class);
            reader.setCoverageExecutions(coverageExecutions);
            if (resultsFolders.getCoverageInfoFile().exists()) {
                CoverageSelectionInfo coverageInfo = Constants.OBJECTMAPPER.readValue(resultsFolders.getCoverageInfoFile(), CoverageSelectionInfo.class);
                reader.setCoverageInfo(coverageInfo);
            }
        }
        reader.readDependencies();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) IOException(java.io.IOException) File(java.io.File) CoverageSelectionInfo(de.dagere.peass.dependency.traces.coverage.CoverageSelectionInfo) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 2 with VersionKeeper

use of de.dagere.peass.dependency.reader.VersionKeeper in project peass by DaGeRe.

the class JmhDependencyReaderMultiParamTest method testVersionReading.

@Test
public void testVersionReading() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
        FakeGitUtil.prepareGitUtils(gitUtilsMock);
        FakeFileIterator iterator = mockIterator();
        ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
        TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
        ExecutionConfig jmhConfig = new ExecutionConfig();
        jmhConfig.setTestTransformer("de.dagere.peass.dependency.jmh.JmhTestTransformer");
        jmhConfig.setTestExecutor("de.dagere.peass.dependency.jmh.JmhTestExecutor");
        DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, new VersionKeeper(new File("/dev/null")), jmhConfig, new KiekerConfig(true), new EnvironmentVariables());
        reader.readInitialVersion();
        checkInitialVersion(resultsFolders);
        reader.readDependencies();
        checkChangedVersion(resultsFolders);
    }
}
Also used : TestSelectionConfig(de.dagere.peass.config.TestSelectionConfig) VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.jupiter.api.Test)

Example 3 with VersionKeeper

use of de.dagere.peass.dependency.reader.VersionKeeper in project peass by DaGeRe.

the class JmhDependencyReaderTest method testVersionReading.

@ParameterizedTest
@ArgumentsSource(KiekerConfigurationProvider.class)
public void testVersionReading(final KiekerConfig kiekerConfig) throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
        FakeGitUtil.prepareGitUtils(gitUtilsMock);
        FakeFileIterator iterator = mockIterator();
        ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
        TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
        ExecutionConfig jmhConfig = new ExecutionConfig();
        jmhConfig.setTestTransformer("de.dagere.peass.dependency.jmh.JmhTestTransformer");
        jmhConfig.setTestExecutor("de.dagere.peass.dependency.jmh.JmhTestExecutor");
        DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iterator, new VersionKeeper(new File("/dev/null")), jmhConfig, kiekerConfig, new EnvironmentVariables());
        reader.readInitialVersion();
        checkInitialVersion(resultsFolders);
        reader.readDependencies();
        checkChangedVersion(resultsFolders);
    }
}
Also used : TestSelectionConfig(de.dagere.peass.config.TestSelectionConfig) VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) PeassFolders(de.dagere.peass.folders.PeassFolders) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 4 with VersionKeeper

use of de.dagere.peass.dependency.reader.VersionKeeper in project peass by DaGeRe.

the class ContinuousDependencyReader method getDependencies.

StaticTestSelection getDependencies(final VersionIterator iterator, final String url) {
    try {
        StaticTestSelection dependencies;
        final VersionKeeper noChanges = new VersionKeeper(new File(resultsFolders.getStaticTestSelectionFile().getParentFile(), "nonChanges_" + folders.getProjectName() + ".json"));
        if (!resultsFolders.getStaticTestSelectionFile().exists()) {
            LOG.debug("Fully loading dependencies");
            dependencies = fullyLoadDependencies(url, iterator, noChanges);
        } else {
            LOG.debug("Partially loading dependencies");
            dependencies = Constants.OBJECTMAPPER.readValue(resultsFolders.getStaticTestSelectionFile(), StaticTestSelection.class);
            VersionComparator.setDependencies(dependencies);
            if (iterator != null) {
                executePartialRTS(dependencies, iterator);
            }
        }
        VersionComparator.setDependencies(dependencies);
        return dependencies;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) File(java.io.File) ViewNotFoundException(de.dagere.peass.dependencyprocessors.ViewNotFoundException) ParseException(com.github.javaparser.ParseException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Example 5 with VersionKeeper

use of de.dagere.peass.dependency.reader.VersionKeeper in project peass by DaGeRe.

the class GetProjectSizes method main.

public static void main(final String[] args) throws JsonParseException, JsonMappingException, IOException {
    File dependencyFolder;
    if (System.getenv(Constants.PEASS_REPOS) != null) {
        final String repofolder = System.getenv(Constants.PEASS_REPOS);
        final File folder = new File(repofolder);
        dependencyFolder = new File(folder, "dependencies-final");
    } else {
        throw new RuntimeException("Please define environment variable " + Constants.PEASS_REPOS);
    }
    System.out.println("Projekt & Versionen & Analysierbar & GeƤndert & Selektiert & Tests\\\\ \\hline");
    for (final String project : allProjects) {
        final File projectFolder = new File("../../projekte/" + project);
        final int commits = GitUtils.getCommits(projectFolder, true).size();
        final File executionFile = new File(dependencyFolder, ResultsFolders.TRACE_SELECTION_PREFIX + project + ".json");
        int analyzable = 0;
        int tests = 0;
        int executionTests = 0;
        if (executionFile.exists()) {
            final ExecutionData executionData = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
            executionTests = executionData.getVersions().size();
            for (final TestSet test : executionData.getVersions().values()) {
                tests += test.getTests().size();
            }
        }
        final File nonRunning = new File(dependencyFolder, "nonRunning_" + project + ".json");
        final File nonChanges = new File(dependencyFolder, "nonChanges_" + project + ".json");
        int changes = 0;
        if (nonRunning.exists()) {
            final VersionKeeper vk = Constants.OBJECTMAPPER.readValue(nonRunning, VersionKeeper.class);
            analyzable = commits - vk.getNonRunableReasons().size();
            if (nonChanges.exists()) {
                final VersionKeeper vk2 = Constants.OBJECTMAPPER.readValue(nonChanges, VersionKeeper.class);
                changes = analyzable - vk2.getNonRunableReasons().size();
            }
        }
        System.out.println(project + " & " + commits + " & " + analyzable + " & " + changes + " & " + executionTests + " & " + tests + "\\\\");
    }
}
Also used : VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) File(java.io.File) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Aggregations

VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)7 File (java.io.File)7 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)5 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)4 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)4 PeassFolders (de.dagere.peass.folders.PeassFolders)4 TestSelectionConfig (de.dagere.peass.config.TestSelectionConfig)3 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)3 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)3 ResultsFolders (de.dagere.peass.folders.ResultsFolders)3 GitUtils (de.dagere.peass.vcs.GitUtils)3 KiekerConfig (de.dagere.peass.config.KiekerConfig)2 IOException (java.io.IOException)2 Test (org.junit.jupiter.api.Test)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ParseException (com.github.javaparser.ParseException)1 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)1 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)1 CoverageSelectionInfo (de.dagere.peass.dependency.traces.coverage.CoverageSelectionInfo)1