importJava "java.lang.System" where
@JavaName "getProperty"
- getSystemProperty :: String -> String
+ getSystemProperty :: String -> Maybe String
importJava "org.simantics.modeling.LifeCycleContext" where
data LifeCycleContext
private final CommandSession session;
private final BufferedReader reader;
private final SCLReportingHandler handler;
+ private boolean ignorePrints;
public TestScriptExecutor(CommandSession session, BufferedReader reader, SCLReportingHandler handler) {
+ this(session, reader, handler, false);
+ }
+
+ public TestScriptExecutor(CommandSession session, BufferedReader reader, SCLReportingHandler handler, boolean ignorePrints) {
this.session = session;
this.reader = reader;
this.handler = handler == null ? SCLReportingHandler.DEFAULT : handler;
+ this.ignorePrints = ignorePrints;
}
public void execute() throws IOException {
@Override
public void print(String text) {
handler.print(text);
- actualResponse.append(text).append('\n');
+ if (!ignorePrints)
+ actualResponse.append(text).append('\n');
}
@Override
import org.cojen.classfile.TypeDesc;
import org.osgi.service.component.annotations.Component;
+import org.simantics.scl.compiler.commands.CommandSession;
import org.simantics.scl.compiler.common.names.Name;
import org.simantics.scl.compiler.constants.JavaMethod;
import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
@Override
public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
ConcreteModule module = context.getCompilationContext().module;
+ String identifier;
+ if (module != null)
+ identifier = module.getName().replaceAll("/", ".");
+ else
+ identifier = CommandSession.class.getName();
apply.set(new ELiteral(javaMethod), new Expression[] {
- new EExternalConstant(LoggerFactory.getLogger(module.getName().replaceAll("/", ".")), Logger),
+ new EExternalConstant(LoggerFactory.getLogger(identifier), Logger),
apply.parameters[0]
});
return apply;
package org.simantics.scl.compiler.internal.codegen.utils;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.simantics.scl.runtime.function.FunctionImpl1;
Object ret = method.invoke(null, p0);
return returnsVoid ? Tuple0.INSTANCE : ret;
} catch (ReflectiveOperationException e) {
+ if (e instanceof InvocationTargetException)
+ throw new RuntimeException(e.getCause());
throw new RuntimeException(e);
}
}
package org.simantics.scl.osgi;
+import java.util.ArrayList;
+
+import org.simantics.scl.compiler.errors.DoesNotExist;
+import org.simantics.scl.compiler.errors.Failable;
+import org.simantics.scl.compiler.module.Module;
import org.simantics.scl.compiler.module.repository.ModuleRepository;
import org.simantics.scl.compiler.source.repository.ModuleSourceRepository;
import org.simantics.scl.compiler.testing.repository.TestRepository;
import org.simantics.scl.osgi.internal.ServiceBasedModuleSourceRepository;
import org.simantics.scl.osgi.internal.ServiceBasedTestRepository;
+import gnu.trove.procedure.TObjectProcedure;
+
public class SCLOsgi {
public static ModuleRepository MODULE_REPOSITORY = new ModuleRepository(SOURCE_REPOSITORY);
public static TestRepository TEST_REPOSITORY = new ServiceBasedTestRepository(Activator.getContext());
+
+ public static String compileAllModules() {
+ ArrayList<String> modulesWithErrors = new ArrayList<String>();
+ SCLOsgi.SOURCE_REPOSITORY.forAllModules(new TObjectProcedure<String>() {
+ @Override
+ public boolean execute(String moduleName) {
+ System.out.print(moduleName);
+ System.out.print(" - ");
+ Failable<Module> module = SCLOsgi.MODULE_REPOSITORY.getModule(moduleName);
+ if(module.didSucceed())
+ System.out.println("succeeded");
+ else if(module == DoesNotExist.INSTANCE)
+ System.out.println("does not exist"); // should not happen
+ else {
+ System.out.println("error");
+ modulesWithErrors.add(moduleName);
+ }
+ return true;
+ }
+ });
+ if(!modulesWithErrors.isEmpty()) {
+ StringBuilder b = new StringBuilder();
+ b.append("Some SCL modules failed to compile:");
+ for(String module : modulesWithErrors)
+ b.append(' ').append(module);
+ return b.toString();
+ }
+ return null;
+ }
}
package org.simantics.scl.osgi.tests;
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.AfterClass;
import org.simantics.application.arguments.IArgumentFactory;
import org.simantics.application.arguments.IArguments;
import org.simantics.application.arguments.SimanticsArguments;
-import org.simantics.scl.compiler.errors.DoesNotExist;
-import org.simantics.scl.compiler.errors.Failable;
-import org.simantics.scl.compiler.module.Module;
import org.simantics.scl.osgi.SCLOsgi;
-import gnu.trove.procedure.TObjectProcedure;
-
-
public class TestSCLOsgi {
private static IProgressMonitor progress = new NullProgressMonitor();
@Test
public void testDataJsonExists() {
- ArrayList<String> modulesWithErrors = new ArrayList<String>();
- SCLOsgi.SOURCE_REPOSITORY.forAllModules(new TObjectProcedure<String>() {
- @Override
- public boolean execute(String moduleName) {
- System.out.print(moduleName);
- System.out.print(" - ");
- Failable<Module> module = SCLOsgi.MODULE_REPOSITORY.getModule(moduleName);
- if(module.didSucceed())
- System.out.println("succeeded");
- else if(module == DoesNotExist.INSTANCE)
- System.out.println("does not exist"); // should not happen
- else {
- System.out.println("error");
- modulesWithErrors.add(moduleName);
- }
- return true;
- }
- });
- if(!modulesWithErrors.isEmpty()) {
- StringBuilder b = new StringBuilder();
- b.append("Some SCL modules failed to compile:");
- for(String module : modulesWithErrors)
- b.append(' ').append(module);
- Assert.fail(b.toString());
+ String possibleError = SCLOsgi.compileAllModules();
+ if(possibleError != null) {
+ Assert.fail(possibleError);
}
}
}