Search in sources :

Example 6 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.

the class GradleInjectorTest method testOnGradleFromActiveonWithoutMavenRepositoryPluginsGradle.

@Test
public void testOnGradleFromActiveonWithoutMavenRepositoryPluginsGradle() {
    /*
            test the injection of what we need in the build.gradle when we removed the
                maven {
                    url "https://plugins.gradle.org/m2/"
                }
         */
    UserInput configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot("src/test/");
    configuration.setExcludedClasses("fr.inria.filter.failing.*");
    configuration.setJVMArgs("-Xmx2048m,-Xms1024m");
    configuration.setFilter("fr.inria.sample.*");
    final GradleInjector gradleInjector = new GradleInjector("src/test/resources/no_repository_build.gradle", !configuration.isGregorMode(), configuration.getFilter(), configuration.getPitVersion(), configuration.getTimeOutInMs(), configuration.getJVMArgs(), configuration.getExcludedClasses(), configuration.getAdditionalClasspathElements());
    final String pitTask = gradleInjector.getPitTask();
    assertTrue(pitTask, pitTask.startsWith(expectedStarts));
    assertTrue(pitTask, pitTask.endsWith(expectedEnd));
}
Also used : UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Test(org.junit.Test)

Example 7 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.

the class MavenAutomaticBuilderTest method setUp.

public void setUp(String path, String filter, boolean isDescartesMode, String additionalClasspathElements) {
    this.parser = new PitXMLResultParser();
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot(new File(path).getAbsolutePath());
    this.configuration.setGregorMode(!isDescartesMode);
    this.configuration.setFilter(filter);
    this.configuration.setAdditionalClasspathElements(additionalClasspathElements);
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(this.configuration);
    DSpotPOMCreator.createNewPom(this.configuration);
    this.launcher = new Launcher();
    this.launcher.addInputResource(path + "/src/");
    this.launcher.getEnvironment().setNoClasspath(true);
    this.launcher.buildModel();
    DSpotState.verbose = true;
    try {
        FileUtils.deleteDirectory(new File(path + "/target/"));
    } catch (IOException ignored) {
    // ignored
    }
    builder.compileAndBuildClasspath();
}
Also used : PitXMLResultParser(eu.stamp_project.dspot.selector.pitmutantscoreselector.PitXMLResultParser) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) IOException(java.io.IOException) File(java.io.File)

Example 8 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.

the class DSpotCompilerTest method testDSpotCompiler.

// TODO update with configuration
@Test
public void testDSpotCompiler() throws Exception {
    final UserInput configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot("src/test/resources/test-projects/");
    final DSpotCompiler compiler = DSpotCompiler.createDSpotCompiler(configuration, "");
    TestCompiler testCompiler = new TestCompiler(0, false, configuration.getAbsolutePathToProjectRoot(), configuration.getClasspathClassesProject(), 10000, "", false);
    final CtClass<?> aClass = getClass(compiler.getLauncher().getFactory());
    final List<CtMethod<?>> method = aClass.getMethodsByName("method");
    final List<CtMethod<?>> compile = testCompiler.compileAndDiscardUncompilableMethods(compiler, aClass, method);
    assertEquals(1, compile.size());
    assertEquals(1, aClass.getMethods().size());
    final List<CtMethod<?>> tests = new UncompilableAmplifier().amplify(method.get(0), 0).collect(Collectors.toList());
    tests.forEach(aClass::addMethod);
    assertEquals(3, aClass.getMethods().size());
    final CtMethod uncompilableTest = tests.stream().filter(ctMethod -> ctMethod.getSimpleName().equals("compilableTest")).findFirst().get();
    final List<CtMethod<?>> results = testCompiler.compileAndDiscardUncompilableMethods(compiler, aClass, new ArrayList(aClass.getMethods()));
    assertEquals(2, results.size());
    assertEquals("compilableTest", results.get(0).getSimpleName());
    assertEquals(uncompilableTest, results.get(0));
    assertEquals(2, aClass.getMethods().size());
}
Also used : ArrayList(java.util.ArrayList) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Example 9 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.

the class AbstractSelectorRemoveOverlapTest method setUp.

@Before
public void setUp() {
    DSpotState.verbose = true;
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot(getPathToAbsoluteProjectRoot());
    this.configuration.setOutputDirectory(outputDirectory);
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    this.initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, this.builder);
    DSpotUtils.init(CommentEnum.None, outputDirectory, this.configuration.getFullClassPathWithExtraDependencies(), this.getPathToAbsoluteProjectRoot());
    this.compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
    DSpotCache.init(10000);
    Launcher launcher = new Launcher();
    launcher.getEnvironment().setNoClasspath(true);
    launcher.addInputResource(this.getPathToAbsoluteProjectRoot());
    launcher.buildModel();
    this.factory = launcher.getFactory();
    TestFramework.init(this.factory);
    this.testCompiler = new TestCompiler(0, false, this.getPathToAbsoluteProjectRoot(), this.configuration.getClasspathClassesProject(), 10000, "", false);
    AssertionGeneratorUtils.init(false);
    DSpotPOMCreator.createNewPom(configuration);
    RandomHelper.setSeedRandom(72L);
    ValueCreator.count = 0;
    this.testSelectorUnderTest = this.getTestSelector();
}
Also used : TestCompiler(eu.stamp_project.dspot.common.compilation.TestCompiler) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) Before(org.junit.Before)

Example 10 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.

the class GradleAutomaticBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    // assumeTrue("true".equals(System.getProperty("doIntegrationTests")));
    DSpotState.verbose = true;
    cleanTestEnv();
    LOGGER.debug("Test Set-up - Reading input parameters...");
    LOGGER.debug("Test Set-up - instantiating Automatic Builder (SUT)...");
    final UserInput configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot(this.pathToProjectRoot);
    configuration.setGregorMode(true);
    configuration.setFilter("example.*");
    launcher = new Launcher();
    launcher.addInputResource(pathToProjectRoot + "src/");
    launcher.getEnvironment().setNoClasspath(true);
    launcher.buildModel();
    sut = AutomaticBuilderEnum.Gradle.getAutomaticBuilder(configuration);
    sut.compile();
    LOGGER.debug("Test Set-up complete.");
    parser = new PitXMLResultParser();
}
Also used : PitXMLResultParser(eu.stamp_project.dspot.selector.pitmutantscoreselector.PitXMLResultParser) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) Before(org.junit.Before)

Aggregations

UserInput (eu.stamp_project.dspot.common.configuration.UserInput)26 Before (org.junit.Before)11 Test (org.junit.Test)10 InitializeDSpot (eu.stamp_project.dspot.common.configuration.InitializeDSpot)8 Launcher (spoon.Launcher)8 File (java.io.File)7 AutomaticBuilder (eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder)5 TestCompiler (eu.stamp_project.dspot.common.compilation.TestCompiler)4 PitXMLResultParser (eu.stamp_project.dspot.selector.pitmutantscoreselector.PitXMLResultParser)3 BufferedReader (java.io.BufferedReader)3 FileReader (java.io.FileReader)3 TestRunner (eu.stamp_project.dspot.common.execution.TestRunner)2 ArrayList (java.util.ArrayList)2 CtMethod (spoon.reflect.declaration.CtMethod)2 DSpot (eu.stamp_project.dspot.DSpot)1 DSpotState (eu.stamp_project.dspot.common.configuration.DSpotState)1 InputErrorException (eu.stamp_project.dspot.common.configuration.check.InputErrorException)1 DSpotUtils (eu.stamp_project.dspot.common.miscellaneous.DSpotUtils)1 JacocoCoverageSelector (eu.stamp_project.dspot.selector.JacocoCoverageSelector)1 IOException (java.io.IOException)1