public List<CommandSessionVariable> run(List<CommandSessionVariable> vars) throws IOException {
ModuleRepository repo = new ModuleRepository(SCLOsgi.SOURCE_REPOSITORY);
- repo.setAdvisor(new ModuleCompilationOptionsAdvisor() {
+ try {
+ repo.setAdvisor(new ModuleCompilationOptionsAdvisor() {
+
+ @Override
+ public ModuleCompilationOptions getOptions(String moduleName) {
+ // TODO: default to false
+ boolean coverage = true;
+ // TODO: add moduleName filters back
+ // for (Pattern p : getModuleNameFilterPatterns()) {
+ // if (p.matcher(moduleName.toLowerCase()).find()) {
+ // coverage = true;
+ // break;
+ // }
+ // }
+ return new ModuleCompilationOptions(coverage);
+ }
+ });
- @Override
- public ModuleCompilationOptions getOptions(String moduleName) {
- // TODO: default to false
- boolean coverage = true;
- // TODO: add moduleName filters back
-// for (Pattern p : getModuleNameFilterPatterns()) {
-// if (p.matcher(moduleName.toLowerCase()).find()) {
-// coverage = true;
-// break;
-// }
-// }
- return new ModuleCompilationOptions(coverage);
- }
- });
-
- SCLReportingHandler handler = (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
- CommandSession session = new CommandSession(repo, handler);
-
- for (CommandSessionVariable var : vars)
- session.setVariable(var.getName(), var.getType(), var.getValue());
-
- for (Map.Entry<String, String> entry : variables.entrySet())
- session.setVariable(entry.getKey(), Types.STRING, entry.getValue());
-
- new TestScriptExecutor(session, new BufferedReader(new StringReader(code)), handler, true).execute();
- STSSuiteTestCollector.setTestCoverage(this, session);
-
- // Return variables from this session
- List<CommandSessionVariable> result = new ArrayList<>();
- for (String var : session.getVariables())
- result.add(new CommandSessionVariable(var, session.getVariableType(var), session.getVariableValue(var)));
-
- return result;
+ SCLReportingHandler handler = (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
+ CommandSession session = new CommandSession(repo, handler);
+
+ for (CommandSessionVariable var : vars)
+ session.setVariable(var.getName(), var.getType(), var.getValue());
+
+ for (Map.Entry<String, String> entry : variables.entrySet())
+ session.setVariable(entry.getKey(), Types.STRING, entry.getValue());
+
+ new TestScriptExecutor(session, new BufferedReader(new StringReader(code)), handler, true).execute();
+ STSSuiteTestCollector.setTestCoverage(this, session);
+
+ // Return variables from this session
+ List<CommandSessionVariable> result = new ArrayList<>();
+ for (String var : session.getVariables())
+ result.add(new CommandSessionVariable(var, session.getVariableType(var), session.getVariableValue(var)));
+
+ return result;
+ } finally {
+ // remember to flush this repository
+ repo.flush();
+ }
}
public Set<String> getDependencies() {