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;
}
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));
}
});
}
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);
}
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");
}
}
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);
}
}
Aggregations