1 package org.simantics.scl.compiler.tests;
3 import java.io.BufferedReader;
4 import java.io.InputStreamReader;
5 import java.nio.charset.Charset;
7 import org.junit.Before;
8 import org.simantics.scl.compiler.commands.CommandSession;
9 import org.simantics.scl.compiler.commands.TestScriptExecutor;
10 import org.simantics.scl.compiler.module.repository.ModuleRepository;
11 import org.simantics.scl.compiler.source.repository.CompositeModuleSourceRepository;
12 import org.simantics.scl.compiler.source.repository.SourceRepositories;
14 public class ScriptTestBase {
16 private final String path;
18 ModuleRepository moduleRepository;
20 public ScriptTestBase(String path) {
25 public void initialize() throws Exception {
26 moduleRepository = new ModuleRepository(
27 new CompositeModuleSourceRepository(
28 SourceRepositories.BUILTIN_SOURCE_REPOSITORY,
29 SourceRepositories.PRELUDE_SOURCE_REPOSITORY
33 protected void test() throws Exception {
34 String testScriptName = Thread.currentThread().getStackTrace()[2].getMethodName();
35 String testPath = "scripts/" + testScriptName + ".sts";
37 CommandSession session = new CommandSession(moduleRepository, null);
38 new TestScriptExecutor(session,
40 new InputStreamReader(getClass().getResourceAsStream(testPath), Charset.forName("UTF-8"))),