Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java @ 21490:3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Tue, 26 May 2015 19:11:36 +0200 |
parents | 286aef83a9a7 |
children | 31fc2fce38f3 |
comparison
equal
deleted
inserted
replaced
21489:b3f1d8b23037 | 21490:3286fb5fea4a |
---|---|
35 import org.junit.runner.notification.*; | 35 import org.junit.runner.notification.*; |
36 import org.junit.runners.*; | 36 import org.junit.runners.*; |
37 import org.junit.runners.model.*; | 37 import org.junit.runners.model.*; |
38 | 38 |
39 import com.oracle.truffle.api.dsl.*; | 39 import com.oracle.truffle.api.dsl.*; |
40 import com.oracle.truffle.api.source.Source; | 40 import com.oracle.truffle.api.vm.TruffleVM; |
41 import com.oracle.truffle.sl.SLMain; | 41 import com.oracle.truffle.sl.SLMain; |
42 import com.oracle.truffle.sl.builtins.*; | 42 import com.oracle.truffle.sl.builtins.*; |
43 import com.oracle.truffle.sl.factory.*; | |
44 import com.oracle.truffle.sl.runtime.*; | |
45 import com.oracle.truffle.sl.test.SLTestRunner.TestCase; | 43 import com.oracle.truffle.sl.test.SLTestRunner.TestCase; |
46 | 44 |
47 public final class SLTestRunner extends ParentRunner<TestCase> { | 45 public final class SLTestRunner extends ParentRunner<TestCase> { |
48 | 46 |
49 private static int repeats = 1; | 47 private static int repeats = 1; |
165 notifier.fireTestStarted(testCase.name); | 163 notifier.fireTestStarted(testCase.name); |
166 | 164 |
167 ByteArrayOutputStream out = new ByteArrayOutputStream(); | 165 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
168 PrintWriter printer = new PrintWriter(out); | 166 PrintWriter printer = new PrintWriter(out); |
169 try { | 167 try { |
170 SLContext context = SLContextFactory.create(new BufferedReader(new StringReader(repeat(testCase.testInput, repeats))), printer); | 168 TruffleVM vm = TruffleVM.newVM().stdIn(new BufferedReader(new StringReader(repeat(testCase.testInput, repeats)))).stdOut(printer).build(); |
171 for (NodeFactory<? extends SLBuiltinNode> builtin : builtins) { | 169 |
172 context.installBuiltin(builtin); | 170 String script = readAllLines(testCase.path); |
173 } | 171 SLMain.run(vm, testCase.path.toUri(), null, printer, repeats, builtins); |
174 /* | |
175 * TruffleVM vm = TruffleVM.create(); String script = readAllLines(testCase.path); for | |
176 * (int i = 0; i < repeats; i++) { vm.eval("application/x-sl", script); } | |
177 */ | |
178 final Source source = Source.fromText(readAllLines(testCase.path), testCase.sourceName); | |
179 SLMain.run(context, source, null, repeats); | |
180 | 172 |
181 printer.flush(); | 173 printer.flush(); |
182 String actualOutput = new String(out.toByteArray()); | 174 String actualOutput = new String(out.toByteArray()); |
183 Assert.assertEquals(repeat(testCase.expectedOutput, repeats), actualOutput); | 175 Assert.assertEquals(script, repeat(testCase.expectedOutput, repeats), actualOutput); |
184 } catch (Throwable ex) { | 176 } catch (Throwable ex) { |
185 notifier.fireTestFailure(new Failure(testCase.name, ex)); | 177 notifier.fireTestFailure(new Failure(testCase.name, new IllegalStateException("Cannot run " + testCase.sourceName, ex))); |
186 } finally { | 178 } finally { |
187 notifier.fireTestFinished(testCase.name); | 179 notifier.fireTestFinished(testCase.name); |
188 } | 180 } |
189 } | 181 } |
190 | 182 |