use of fr.inria.diversify.utils.sosiefier.InputProgram in project Ex2Amplifier by STAMP-project.
the class JBSERunnerTest method test2.
@Test
public void test2() throws Exception {
/*
Same as Test, but on another test method (compareTo).
In this case, there is also a parameter in the second operand
*/
final InputProgram program = configuration.getInputProgram();
final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(configuration).buildClasspath(program.getProgramDir()) + ":" + program.getProgramDir() + program.getClassesDir() + ":" + program.getProgramDir() + program.getTestClassesDir();
final CtMethod<?> testMethod = this.launcher.getFactory().Class().get("fr.inria.calculator.CalculatorTest").getMethodsByName("testCompareToWithParameters").get(0);
final List<Map<String, List<String>>> conditionOnVariablesForEachState = JBSERunner.runJBSE(classpath, testMethod);
assertEquals("[{param1=[param1 > param2]}, {param1=[param1 <= param2]}]", conditionOnVariablesForEachState.toString());
}
use of fr.inria.diversify.utils.sosiefier.InputProgram in project Ex2Amplifier by STAMP-project.
the class JBSERunnerTest method test.
@Test
public void test() throws Exception {
/*
Test the run method of JBSERunner. JBSE should return a List of Map,
that associates a name of parameter to its constraints to reach each state.
Parameter are extracted literals from test.
*/
final InputProgram program = this.configuration.getInputProgram();
final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(this.configuration).buildClasspath(program.getProgramDir()) + ":" + program.getProgramDir() + program.getClassesDir() + ":" + program.getProgramDir() + program.getTestClassesDir();
final CtMethod<?> testMethod = this.launcher.getFactory().Class().get("fr.inria.calculator.CalculatorTest").getMethodsByName("testAccumulateWithParameters").get(0);
final List<Map<String, List<String>>> conditionOnVariablesForEachState = JBSERunner.runJBSE(classpath, testMethod);
assertEquals(2, conditionOnVariablesForEachState.size());
assertEquals("[{param1=[param1 % 3 == 0]}, {param1=[param1 % 3 != 0]}]", conditionOnVariablesForEachState.toString());
}
use of fr.inria.diversify.utils.sosiefier.InputProgram in project Ex2Amplifier by STAMP-project.
the class JBSERunnterTest2 method test.
@Test
public void test() throws Exception {
final InputProgram program = configuration.getInputProgram();
final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(configuration).buildClasspath(program.getProgramDir()) + ":" + program.getProgramDir() + program.getClassesDir() + ":" + program.getProgramDir() + program.getTestClassesDir();
final CtClass<?> mainClass = this.launcher.getFactory().Class().get("fr.inria.stamp.MainTest");
final CtMethod<?> testMethod = mainClass.getMethodsByName("test3").get(0);
final CtMethod<?> ctMethod = ArgumentsExtractor.performExtraction(testMethod);
mainClass.addMethod(ctMethod);
DSpotUtils.printCtTypeToGivenDirectory(mainClass, new File("target/dspot/tmp_test_sources"));
DSpotCompiler.compile("target/dspot/tmp_test_sources", classpath, new File(this.configuration.getInputProgram().getProgramDir() + "/" + this.configuration.getInputProgram().getTestClassesDir()));
final List<Map<String, List<String>>> conditionOnVariablesForEachState = JBSERunner.runJBSE(classpath, ctMethod);
System.out.println(conditionOnVariablesForEachState);
}
use of fr.inria.diversify.utils.sosiefier.InputProgram 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.InputProgram in project dspot by STAMP-project.
the class CloverCoverageSelector method selectToAmplify.
@Override
public List<CtMethod<?>> selectToAmplify(List<CtMethod<?>> testsToBeAmplified) {
if (this.currentClassTestToBeAmplified == null && !testsToBeAmplified.isEmpty()) {
this.currentClassTestToBeAmplified = testsToBeAmplified.get(0).getDeclaringType();
final Map<String, Map<String, List<Integer>>> lineCoveragePerTestMethods = CloverExecutor.executeAll(this.configuration, PATH_TO_COPIED_FILES);
this.originalLineCoveragePerClass = new HashMap<>();
final InputProgram program = this.configuration.getInputProgram();
lineCoveragePerTestMethods.keySet().stream().map(lineCoveragePerTestMethods::get).forEach(lineCoveragePerTestMethod -> lineCoveragePerTestMethod.keySet().forEach(className -> {
final CtType<?> key = program.getFactory().Type().get(className);
if (!this.originalLineCoveragePerClass.containsKey(key)) {
this.originalLineCoveragePerClass.put(key, new HashSet<>());
}
this.originalLineCoveragePerClass.get(key).addAll(lineCoveragePerTestMethod.get(className));
}));
final String classesOfProject = program.getProgramDir() + program.getClassesDir() + AmplificationHelper.PATH_SEPARATOR + program.getProgramDir() + program.getTestClassesDir();
final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(this.configuration).buildClasspath(program.getProgramDir()) + AmplificationHelper.PATH_SEPARATOR + classesOfProject;
this.initialCoverage = EntryPoint.runCoverageOnTestClasses(classpath, classesOfProject, DSpotUtils.getAllTestClasses(configuration));
}
if (testsToBeAmplified.size() > 1) {
final List<CtMethod<?>> collect = testsToBeAmplified.stream().filter(this.selectedAmplifiedTest::contains).collect(Collectors.toList());
if (collect.isEmpty()) {
return testsToBeAmplified;
} else {
return collect;
}
} else {
return testsToBeAmplified;
}
}
Aggregations