Search in sources :

Example 16 with InputProgram

use of fr.inria.diversify.utils.sosiefier.InputProgram in project dspot by STAMP-project.

the class DSpotCompilerTest method getInputProgram.

private InputProgram getInputProgram() {
    final File tmpDir = new File("tmpDir");
    if (tmpDir.exists()) {
        try {
            FileUtils.cleanDirectory(tmpDir);
        } catch (IOException ignored) {
        // ignored
        }
    }
    final InputProgram inputProgram = new InputProgram();
    inputProgram.setProgramDir("target/dspot/trash/");
    inputProgram.setRelativeSourceCodeDir("src/main/java/");
    inputProgram.setRelativeTestSourceCodeDir("src/test/java");
    return inputProgram;
}
Also used : IOException(java.io.IOException) File(java.io.File) InputProgram(fr.inria.diversify.utils.sosiefier.InputProgram)

Example 17 with InputProgram

use of fr.inria.diversify.utils.sosiefier.InputProgram in project dspot by STAMP-project.

the class DSpotUtils method copyGivenResources.

private static void copyGivenResources(String resources, String outputDirectory, InputConfiguration configuration) {
    final InputProgram program = configuration.getInputProgram();
    Arrays.stream(resources.split(PATH_SEPARATOR)).forEach(resource -> {
        if (new File(program.getProgramDir() + resource).isDirectory()) {
            copyDirectory(program.getProgramDir(), resource, program.getProgramDir() + outputDirectory);
        } else {
            copyFile(program.getProgramDir(), resource, program.getProgramDir() + outputDirectory, new File(program.getProgramDir() + resource));
        }
    });
}
Also used : File(java.io.File) InputProgram(fr.inria.diversify.utils.sosiefier.InputProgram)

Example 18 with InputProgram

use of fr.inria.diversify.utils.sosiefier.InputProgram in project dspot by STAMP-project.

the class Initializer method initialize.

public static void initialize(InputConfiguration configuration) throws IOException, InterruptedException {
    InputProgram program = InputConfiguration.initInputProgram(configuration);
    program.setProgramDir(DSpotUtils.computeProgramDirectory.apply(configuration));
    configuration.setInputProgram(program);
    Initializer.initialize(configuration, program);
}
Also used : InputProgram(fr.inria.diversify.utils.sosiefier.InputProgram)

Example 19 with InputProgram

use of fr.inria.diversify.utils.sosiefier.InputProgram in project dspot by STAMP-project.

the class Initializer method compileTest.

public static void compileTest(InputConfiguration configuration) {
    InputProgram program = configuration.getInputProgram();
    String dependencies = AutomaticBuilderFactory.getAutomaticBuilder(configuration).buildClasspath(program.getProgramDir());
    dependencies += PATH_SEPARATOR + "target/dspot/dependencies/";
    File output = new File(program.getProgramDir() + "/" + program.getClassesDir());
    File outputTest = new File(program.getProgramDir() + "/" + program.getTestClassesDir());
    try {
        FileUtils.cleanDirectory(outputTest);
    } catch (Exception ignored) {
    // the target directory does not exist, do not need to clean it
    }
    boolean statusTest = DSpotCompiler.compile(program.getAbsoluteTestSourceCodeDir(), output.getAbsolutePath() + PATH_SEPARATOR + dependencies, outputTest);
    if (!statusTest) {
        throw new RuntimeException("Error during compilation");
    }
}
Also used : File(java.io.File) IOException(java.io.IOException) InputProgram(fr.inria.diversify.utils.sosiefier.InputProgram)

Example 20 with InputProgram

use of fr.inria.diversify.utils.sosiefier.InputProgram in project dspot by STAMP-project.

the class TestCompiler method compileAndRun.

public static TestListener compileAndRun(CtType<?> testClass, DSpotCompiler compiler, List<CtMethod<?>> testsToRun, InputConfiguration configuration) {
    final InputProgram inputProgram = configuration.getInputProgram();
    final String dependencies = inputProgram.getProgramDir() + "/" + inputProgram.getClassesDir() + System.getProperty("path.separator") + inputProgram.getProgramDir() + "/" + inputProgram.getTestClassesDir() + System.getProperty("path.separator") + "target/dspot/dependencies/";
    if (!new File("target/dspot/dependencies/compare").exists()) {
        DSpotUtils.copyPackageFromResources("fr/inria/diversify/compare/", "MethodsHandler", "ObjectLog", "Observation", "Utils");
    }
    final List<CtMethod<?>> uncompilableMethods = TestCompiler.compile(compiler, testClass, dependencies);
    if (uncompilableMethods.contains(TestCompiler.METHOD_CODE_RETURN)) {
        return null;
    } else {
        testsToRun.removeAll(uncompilableMethods);
        uncompilableMethods.forEach(testClass::removeMethod);
        if (testsToRun.isEmpty()) {
            return null;
        }
        final String classPath = AmplificationHelper.getClassPath(compiler, configuration);
        return TestLauncher.runFromSpoonNodes(configuration, classPath, testClass, testsToRun);
    }
}
Also used : File(java.io.File) InputProgram(fr.inria.diversify.utils.sosiefier.InputProgram)

Aggregations

InputProgram (fr.inria.diversify.utils.sosiefier.InputProgram)30 Test (org.junit.Test)19 InputConfiguration (fr.inria.diversify.utils.sosiefier.InputConfiguration)12 AbstractTest (fr.inria.AbstractTest)10 CtMethod (spoon.reflect.declaration.CtMethod)10 File (java.io.File)9 Factory (spoon.reflect.factory.Factory)7 AmplificationHelper (fr.inria.diversify.utils.AmplificationHelper)6 List (java.util.List)6 IOException (java.io.IOException)5 CtClass (spoon.reflect.declaration.CtClass)5 Utils (fr.inria.Utils)4 Arrays (java.util.Arrays)4 Map (java.util.Map)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 CtInvocation (spoon.reflect.code.CtInvocation)4 TypeFilter (spoon.reflect.visitor.filter.TypeFilter)4 AbstractTest (eu.stamp.project.ex2amplifier.AbstractTest)3 TestListener (fr.inria.stamp.test.listener.TestListener)3 Collectors (java.util.stream.Collectors)3