use of abs.backend.tests.ABSTestRunnerGenerator in project abstools by abstools.
the class ABSUnitTestExecutionJob method generateTestRunner.
/**
* Generate an ABS file from an ABS project that can be used to execute unit tests
* @throws ParseException Is thrown, if the project which is compiled has parse errors
* @throws TypeCheckerException Is thrown, if the project which is compiled has type errors
* @throws DeltaModellingException
* @throws WrongProgramArgumentException
*/
private void generateTestRunner(IProgressMonitor monitor, AbsNature nature) throws CoreException, IOException, ParseException, TypeCheckerException {
PrintStream ps = null;
FileInputStream fis = null;
try {
// find a way to change
String path = Constants.DEFAULT_MAVEN_TARGET_ABS_PATH;
IFolder folder = project.getFolder(path);
MaudeJob.prepareFolder(monitor, folder);
String fileName = "runner.abs";
final IFile wspaceFile = folder.getFile(fileName);
/* generateMaude only knows how to fill PrintStreams */
final File tmpFile = File.createTempFile(fileName, null);
ps = new PrintStream(tmpFile);
// Get model, check for errors and throw respective exception
Model model = nature.getCompleteModel();
if (model.hasParserErrors()) {
throw new ParseException(model.getParserErrors());
}
if (model.hasTypeErrors()) {
throw new TypeCheckerException(model.typeCheck());
}
String mb = abs.backend.tests.ABSTestRunnerGenerator.RUNNER_MAIN;
ABSTestRunnerGenerator gen = new ASTBasedABSTestRunnerGenerator(model);
gen.generateTestRunner(ps);
ps.close();
fis = new FileInputStream(tmpFile);
if (wspaceFile.exists())
wspaceFile.setContents(fis, true, false, monitor);
else
wspaceFile.create(fis, true, monitor);
fis.close();
tmpFile.delete();
destFile = new File(project.getLocation().append(path).toFile(), fileName);
} finally {
if (ps != null) {
ps.flush();
ps.close();
}
if (fis != null) {
fis.close();
}
}
}
Aggregations