Search in sources :

Example 11 with GitUtils

use of de.dagere.peass.vcs.GitUtils in project peass by DaGeRe.

the class DependencyViewGeneratorTest method testTwoVersions.

@Test
public void testTwoVersions() throws Exception {
    try (MockedStatic<GitUtils> gitUtilsMock = Mockito.mockStatic(GitUtils.class)) {
        FakeGitUtil.prepareGitUtils(gitUtilsMock);
        DependencyDetectorTestUtil.init(TraceGettingIT.BASIC);
        ResultsFolders resultsFolders = new ResultsFolders(TraceGettingIT.VIEW_IT_PROJECTFOLDER, "test");
        TestSelectionConfig dependencyConfig = new TestSelectionConfig(1, false, true, false);
        FakeFileIterator iteratorspied = mockIterator();
        DependencyReader reader = new DependencyReader(dependencyConfig, new PeassFolders(TestConstants.CURRENT_FOLDER), resultsFolders, "", iteratorspied, new VersionKeeper(new File("/dev/null")), new ExecutionConfig(), new KiekerConfig(true), new EnvironmentVariables());
        reader.readInitialVersion();
        try {
            reader.readDependencies();
        } catch (Throwable t) {
            System.out.println();
            for (StackTraceElement te : t.getStackTrace()) {
                System.out.println(te);
            }
            System.out.println();
            throw t;
        }
        File expectedDiff = new File(resultsFolders.getVersionDiffFolder("000002"), "TestMe#test.txt");
        System.out.println(expectedDiff.getAbsolutePath());
        Assert.assertTrue(expectedDiff.exists());
        // TODO Test, that instrumentation sources are not added to the view
        final ExecutionData tests = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
        // 
        Assert.assertEquals(2, tests.getVersions().size());
        Assert.assertEquals(1, tests.getVersions().get("000002").getTests().size());
    }
}
Also used : TestSelectionConfig(de.dagere.peass.config.TestSelectionConfig) VersionKeeper(de.dagere.peass.dependency.reader.VersionKeeper) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ResultsFolders(de.dagere.peass.folders.ResultsFolders) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) Test(org.junit.jupiter.api.Test)

Example 12 with GitUtils

use of de.dagere.peass.vcs.GitUtils in project peass by DaGeRe.

the class TestDependencyTester method testFiles.

@Test
public void testFiles() throws Exception {
    try (MockedStatic<VersionControlSystem> mockedVCS = Mockito.mockStatic(VersionControlSystem.class);
        MockedStatic<ExecutorCreator> mockedExecutor = Mockito.mockStatic(ExecutorCreator.class);
        MockedStatic<GitUtils> utils = Mockito.mockStatic(GitUtils.class)) {
        VCSTestUtils.mockGetVCS(mockedVCS);
        final PeassFolders folders = new PeassFolders(folder.getRoot());
        final MeasurementConfig configuration = new MeasurementConfig(4, "2", "1");
        VCSTestUtils.mockExecutor(mockedExecutor, folders, configuration);
        final DependencyTester tester = new DependencyTester(folders, configuration, new EnvironmentVariables());
        tester.evaluate(EXAMPLE_TESTCASE);
        checkResult(folders);
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) DependencyTester(de.dagere.peass.measurement.dependencyprocessors.DependencyTester) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) GitUtils(de.dagere.peass.vcs.GitUtils) ExecutorCreator(de.dagere.peass.dependency.ExecutorCreator) VersionControlSystem(de.dagere.peass.vcs.VersionControlSystem) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.Test)

Example 13 with GitUtils

use of de.dagere.peass.vcs.GitUtils in project peass by DaGeRe.

the class CauseSearcherIT method testSlowerState.

@Test
public void testSlowerState() throws InterruptedException, IOException, IllegalStateException, XmlPullParserException, AnalysisConfigurationException, ViewNotFoundException, JAXBException {
    try (MockedStatic<VersionControlSystem> mockedVCS = Mockito.mockStatic(VersionControlSystem.class);
        MockedStatic<GitUtils> mockedGitUtils = Mockito.mockStatic(GitUtils.class)) {
        mockEnvironment(mockedVCS, mockedGitUtils);
        final MeasurementConfig measurementConfiguration = new MeasurementConfig(5, VERSION, "000001~1");
        measurementConfiguration.setUseKieker(true);
        final CauseSearcherConfig causeSearcherConfig = CAUSE_CONFIG_TESTME_COMPLETE;
        final CauseSearchFolders folders = new CauseSearchFolders(DependencyTestConstants.CURRENT);
        final BothTreeReader reader = new BothTreeReader(causeSearcherConfig, measurementConfiguration, folders, new EnvironmentVariables());
        EnvironmentVariables emptyEnv = new EnvironmentVariables();
        final CauseTester measurer = new CauseTester(folders, measurementConfiguration, causeSearcherConfig, emptyEnv);
        final CauseSearcher searcher = new CauseSearcherComplete(reader, causeSearcherConfig, measurer, measurementConfiguration, folders, emptyEnv);
        final Set<ChangedEntity> changedEntities = searcher.search();
        checkChangelistContainsChild12(changedEntities);
        File expectedResultLogFolder = folders.getExistingRCALogFolder(VERSION, TESTCASE, 0);
        File expectedResultLogFile = new File(expectedResultLogFolder, "vm_0_" + VERSION);
        Assert.assertTrue("File " + expectedResultLogFolder.getAbsolutePath() + " does not exist ", expectedResultLogFolder.exists());
        Assert.assertTrue("File " + expectedResultLogFile.getAbsolutePath() + " does not exist ", expectedResultLogFile.exists());
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) CauseSearcherComplete(de.dagere.peass.measurement.rca.searcher.CauseSearcherComplete) GitUtils(de.dagere.peass.vcs.GitUtils) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) BothTreeReader(de.dagere.peass.measurement.rca.kieker.BothTreeReader) VersionControlSystem(de.dagere.peass.vcs.VersionControlSystem) CauseSearchFolders(de.dagere.peass.folders.CauseSearchFolders) CauseSearcher(de.dagere.peass.measurement.rca.searcher.CauseSearcher) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) File(java.io.File) Test(org.junit.Test)

Example 14 with GitUtils

use of de.dagere.peass.vcs.GitUtils in project peass by DaGeRe.

the class TestDependencyIteratorBuilder method testNightlyBuildWithoutRunningPrePredecessor.

@Test
public void testNightlyBuildWithoutRunningPrePredecessor() {
    try (MockedStatic<GitUtils> gitUtil = Mockito.mockStatic(GitUtils.class)) {
        gitUtil.when(() -> GitUtils.getName(Mockito.any(), Mockito.any())).thenReturn(VERSION_2);
        ExecutionConfig config = new ExecutionConfig();
        config.setVersionOld(null);
        config.setVersion("HEAD");
        StaticTestSelection dependencies = buildVersionDependencies(SIMPLE_PREDECESSOR);
        dependencies.getVersions().get(SIMPLE_PREDECESSOR).setRunning(false);
        DependencyIteratorBuilder builder = new DependencyIteratorBuilder(config, dependencies, new PeassFolders(TEMPORARY_FOLDER));
        VersionIteratorGit iterator = builder.getIterator();
        Assert.assertNull(iterator);
        Assert.assertEquals(VERSION_2, builder.getVersion());
        Assert.assertEquals(SIMPLE_PREDECESSOR, builder.getVersionOld());
    }
}
Also used : VersionIteratorGit(de.dagere.peass.vcs.VersionIteratorGit) GitUtils(de.dagere.peass.vcs.GitUtils) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.jupiter.api.Test)

Example 15 with GitUtils

use of de.dagere.peass.vcs.GitUtils in project peass by DaGeRe.

the class TestDependencyIteratorBuilder method testNightlyBuildWithPrePredecessor.

@Test
public void testNightlyBuildWithPrePredecessor() {
    try (MockedStatic<GitUtils> gitUtil = Mockito.mockStatic(GitUtils.class)) {
        gitUtil.when(() -> GitUtils.getName(Mockito.any(), Mockito.any())).thenReturn(VERSION_2);
        ExecutionConfig config = new ExecutionConfig();
        config.setVersionOld(null);
        config.setVersion("HEAD");
        StaticTestSelection dependencies = buildVersionDependencies(SIMPLE_PREDECESSOR, VERSION_2);
        DependencyIteratorBuilder builder = new DependencyIteratorBuilder(config, dependencies, new PeassFolders(TEMPORARY_FOLDER));
        VersionIteratorGit iterator = builder.getIterator();
        Assert.assertNull(iterator);
        Assert.assertEquals(VERSION_2, builder.getVersion());
        Assert.assertEquals(SIMPLE_PREDECESSOR, builder.getVersionOld());
    }
}
Also used : VersionIteratorGit(de.dagere.peass.vcs.VersionIteratorGit) GitUtils(de.dagere.peass.vcs.GitUtils) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.jupiter.api.Test)

Aggregations

GitUtils (de.dagere.peass.vcs.GitUtils)17 PeassFolders (de.dagere.peass.folders.PeassFolders)11 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)10 Test (org.junit.jupiter.api.Test)9 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)7 VersionControlSystem (de.dagere.peass.vcs.VersionControlSystem)7 Test (org.junit.Test)7 VersionIteratorGit (de.dagere.peass.vcs.VersionIteratorGit)6 MeasurementConfig (de.dagere.peass.config.MeasurementConfig)5 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)5 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)4 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)4 File (java.io.File)4 TestSelectionConfig (de.dagere.peass.config.TestSelectionConfig)3 VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)3 CauseSearchFolders (de.dagere.peass.folders.CauseSearchFolders)3 ResultsFolders (de.dagere.peass.folders.ResultsFolders)3 KiekerConfig (de.dagere.peass.config.KiekerConfig)2 ExecutorCreator (de.dagere.peass.dependency.ExecutorCreator)2 DependencyTester (de.dagere.peass.measurement.dependencyprocessors.DependencyTester)2