use of org.eclipse.n4js.xpect.ui.results.N4IDEXpectRunListener in project n4js by eclipse.
the class XpectConfigurationDelegate method execute.
/**
* Runs provided File in Engine. Returns output of execution.
*/
public void execute(ILaunch launch, XpectRunConfiguration runConfiguration) throws RuntimeException {
Job job = new Job(launch.getLaunchConfiguration().getName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
XpectRunner xr;
try {
xr = new XpectRunner(N4IDEXpectTestClass.class);
} catch (InitializationError e) {
N4IDEXpectUIPlugin.logError("cannot initialize xpect runner", e);
return Status.CANCEL_STATUS;
}
// TODO support multiple selection
/*
* if Project provided, or package files should be discovered there. Also multiple selected files
*/
String testFileLocation = runConfiguration.getXtFileToRun();
IXpectURIProvider uriprov = xr.getUriProvider();
if (uriprov instanceof N4IDEXpectTestURIProvider) {
((N4IDEXpectTestURIProvider) uriprov).addTestFileLocation(testFileLocation);
}
Result result = new Result();
RunNotifier notifier = new RunNotifier();
RunListener listener = result.createListener();
N4IDEXpectRunListener n4Listener = new N4IDEXpectRunListener();
notifier.addFirstListener(listener);
notifier.addListener(n4Listener);
try {
notifier.fireTestRunStarted(xr.getDescription());
xr.run(notifier);
notifier.fireTestRunFinished(result);
} finally {
notifier.removeListener(n4Listener);
notifier.removeListener(listener);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
Aggregations