use of fr.inria.diversify.utils.sosiefier.InputConfiguration in project dspot by STAMP-project.
the class ChangeDetectorSelector method init.
@Override
public void init(InputConfiguration configuration) {
this.configuration = configuration;
this.program = this.configuration.getInputProgram();
final String configurationPath = configuration.getProperty("configPath");
final String pathToFolder = configuration.getProperty("folderPath");
InputConfiguration inputConfiguration;
try {
inputConfiguration = new InputConfiguration(configurationPath);
InputProgram inputProgram = InputConfiguration.initInputProgram(inputConfiguration);
inputConfiguration.setInputProgram(inputProgram);
this.pathToChangedVersionOfProgram = pathToFolder + DSpotUtils.shouldAddSeparator.apply(pathToFolder) + (inputConfiguration.getProperty("targetModule") != null ? inputConfiguration.getProperty("targetModule") + DSpotUtils.shouldAddSeparator.apply(pathToFolder) : "");
inputProgram.setProgramDir(this.pathToChangedVersionOfProgram);
Initializer.initialize(inputConfiguration, inputProgram);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of fr.inria.diversify.utils.sosiefier.InputConfiguration in project dspot by STAMP-project.
the class MemoryClassLoaderFactory method createMemoryClassLoader.
/*
Here: the factory has the same behavior than @see fr.inria.stamp.test.runner.TestRunnerFactory
We will use the parent of the system classloader in special case
*/
public static MemoryClassLoader createMemoryClassLoader(CtType<?> testClass, InputConfiguration configuration) {
final InputProgram program = configuration.getInputProgram();
final String classesDirectory = program.getProgramDir() + "/" + program.getClassesDir();
final String testClassesDirectory = program.getProgramDir() + "/" + program.getTestClassesDir();
String classpath = AutomaticBuilderFactory.getAutomaticBuilder(configuration).buildClasspath(program.getProgramDir()) + PATH_SEPARATOR + "target/dspot/dependencies/";
ClassLoader classLoader = null;
if (testClass != null && TestRunnerFactory.containsSpecificAnnotation.test(testClass)) {
classLoader = new URLClassLoader(Arrays.stream(classpath.split(":")).map(File::new).map(File::toURI).map(uri -> {
try {
return uri.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}).toArray(URL[]::new), ClassLoader.getSystemClassLoader().getParent());
} else {
classLoader = new URLClassLoader(Arrays.stream(classpath.split(":")).map(File::new).map(File::toURI).map(uri -> {
try {
return uri.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}).toArray(URL[]::new), ClassLoader.getSystemClassLoader());
}
final URL[] urls;
try {
urls = new URL[] { new File(classesDirectory).toURI().toURL(), new File(testClassesDirectory).toURI().toURL() };
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
if (configuration.getProperty("additionalClasspathElements") != null) {
return new MemoryClassLoader(Stream.concat(Arrays.stream(configuration.getProperty("additionalClasspathElements").split(PATH_SEPARATOR)).map(configuration.getInputProgram().getProgramDir()::concat).map(File::new).map(File::toURI).map(uri -> {
try {
return uri.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}), Arrays.stream(urls)).toArray(URL[]::new), classLoader);
} else {
return new MemoryClassLoader(urls, classLoader);
}
}
use of fr.inria.diversify.utils.sosiefier.InputConfiguration in project dspot by STAMP-project.
the class Utils method init.
public static void init(String pathToConfFile) {
try {
FileUtils.forceDelete(new File(inputConfiguration.getOutputDirectory()));
} catch (Exception ignored) {
}
try {
FileUtils.forceDelete(new File("target/dspot/tmp_test_sources/"));
} catch (Exception ignored) {
}
if (pathToConfFile.equals(currentInputConfigurationLoaded)) {
return;
}
try {
AmplificationHelper.minimize = false;
AutomaticBuilderFactory.reset();
if (!new File("target/dspot/dependencies/compare").exists()) {
DSpotUtils.copyPackageFromResources("fr/inria/diversify/compare/", "MethodsHandler", "ObjectLog", "Observation", "Utils");
}
currentInputConfigurationLoaded = pathToConfFile;
inputConfiguration = new InputConfiguration(pathToConfFile);
Initializer.initialize(inputConfiguration);
inputProgram = inputConfiguration.getInputProgram();
builder = AutomaticBuilderFactory.getAutomaticBuilder(inputConfiguration);
String dependencies = builder.buildClasspath(inputProgram.getProgramDir());
if (inputConfiguration.getProperty("additionalClasspathElements") != null) {
dependencies += PATH_SEPARATOR + inputConfiguration.getInputProgram().getProgramDir() + inputConfiguration.getProperty("additionalClasspathElements");
}
compiler = DSpotCompiler.createDSpotCompiler(inputProgram, dependencies);
inputProgram.setFactory(compiler.getLauncher().getFactory());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of fr.inria.diversify.utils.sosiefier.InputConfiguration in project dspot by STAMP-project.
the class AutomaticBuilderFactoryTest method getAutomaticBuilder_whenConfDoesntContainBuilder.
@Test
public void getAutomaticBuilder_whenConfDoesntContainBuilder() throws Exception {
this.configuration = JSAPOptions.parse(getArgsWithNoBuilder());
InputConfiguration inputConfiguration = new InputConfiguration(configuration.pathToConfigurationFile);
InputProgram program = InputConfiguration.initInputProgram(inputConfiguration);
inputConfiguration.setInputProgram(program);
assertTrue(inputConfiguration.getProperty("automaticBuilderName") == null);
AutomaticBuilder builder = AutomaticBuilderFactory.getAutomaticBuilder(inputConfiguration);
assertNotNull(builder);
assertTrue(builder.getClass().equals(MavenAutomaticBuilder.class));
}
use of fr.inria.diversify.utils.sosiefier.InputConfiguration in project dspot by STAMP-project.
the class AutomaticBuilderFactoryTest method getAutomaticBuilder_whenMaven.
@Test
public void getAutomaticBuilder_whenMaven() throws Exception {
this.configuration = JSAPOptions.parse(getArgsWithMavenBuilder());
InputConfiguration inputConfiguration = new InputConfiguration(configuration.pathToConfigurationFile);
InputProgram program = InputConfiguration.initInputProgram(inputConfiguration);
inputConfiguration.setInputProgram(program);
inputConfiguration.getProperties().setProperty("automaticBuilderName", configuration.automaticBuilderName);
assertTrue(inputConfiguration.getProperty("automaticBuilderName").toUpperCase().contains("MAVEN"));
AutomaticBuilder builder = AutomaticBuilderFactory.getAutomaticBuilder(inputConfiguration);
assertNotNull(builder);
assertTrue(builder.getClass().equals(MavenAutomaticBuilder.class));
}
Aggregations