Search in sources :

Example 1 with GitUtils

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

the class TestParallelMeasurement 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> gitUtils = Mockito.mockStatic(GitUtils.class)) {
        VCSTestUtils.mockGetVCS(mockedVCS);
        VCSTestUtils.mockGoToTagEmpty(gitUtils);
        final PeassFolders folders = new PeassFolders(folder.getRoot());
        final MeasurementConfig configuration = new MeasurementConfig(4, "2", "1");
        configuration.setMeasurementStrategy(MeasurementStrategy.PARALLEL);
        MavenTestExecutorMocker.mockExecutor(mockedExecutor, folders, configuration);
        DependencyTester spiedTester = createTesterNoThreads(folders, configuration);
        spiedTester.evaluate(TestDependencyTester.EXAMPLE_TESTCASE);
        TestDependencyTester.checkResult(folders);
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) TestDependencyTester(de.dagere.peass.measurement.analysis.TestDependencyTester) DependencyTester(de.dagere.peass.measurement.dependencyprocessors.DependencyTester) 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 2 with GitUtils

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

the class CoverageBasedSelectionIT method testNormalChange.

@Test
public void testNormalChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    try (MockedStatic<GitUtils> staticMock = Mockito.mockStatic(GitUtils.class)) {
        final ChangeManager changeManager = DependencyDetectorTestUtil.defaultChangeManager();
        final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(DependencyTestConstants.COVERAGE_NORMAL_CHANGE));
        final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator, new ExecutionConfig(5), DependencyTestConstants.DEFAULT_CONFIG_WITH_COVERAGE, DependencyTestConstants.TARGET_RESULTS_FOLDERS);
        System.out.println(reader.getDependencies());
        DependencyDetectorTestUtil.checkChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1, "testFirst");
        System.out.println(reader.getCoverageBasedSelection());
        TestSet tests = reader.getCoverageBasedSelection().getVersions().get(DependencyTestConstants.VERSION_1);
        MatcherAssert.assertThat(tests.getTests(), IsIterableContaining.hasItem(new TestCase("defaultpackage.TestMe#testSecond")));
    }
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 3 with GitUtils

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

the class TestDependencyIteratorBuilder method testNightlyBuildIteratorCreation.

@Test
public void testNightlyBuildIteratorCreation() {
    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(LAST_RUNNING_VERSION);
        VersionIteratorGit iterator = new DependencyIteratorBuilder(config, dependencies, new PeassFolders(TEMPORARY_FOLDER)).getIterator();
        Assert.assertEquals(2, iterator.getSize());
        Assert.assertEquals(VERSION_2, iterator.getTag());
        Assert.assertEquals(LAST_RUNNING_VERSION, iterator.getPredecessor());
    }
}
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 4 with GitUtils

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

the class TestDependencyIteratorBuilder method testRegularIteratorCreation.

@Test
public void testRegularIteratorCreation() {
    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(SIMPLE_PREDECESSOR);
        config.setVersion("HEAD");
        StaticTestSelection dependencies = buildVersionDependencies(LAST_RUNNING_VERSION);
        VersionIteratorGit iterator = new DependencyIteratorBuilder(config, dependencies, new PeassFolders(TEMPORARY_FOLDER)).getIterator();
        Assert.assertEquals(2, iterator.getSize());
        Assert.assertEquals(VERSION_2, iterator.getTag());
        Assert.assertEquals(SIMPLE_PREDECESSOR, iterator.getPredecessor());
    }
}
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 5 with GitUtils

use of de.dagere.peass.vcs.GitUtils 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)

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