Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleRuntimeTest.java @ 22241:14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
- Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget
- Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing
- Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 22 Sep 2015 20:31:19 -0700 |
parents | dc83cc1f94f2 |
children | 0fb3522e5b72 |
comparison
equal
deleted
inserted
replaced
22240:f78c72e2e0b6 | 22241:14e6dfb1ef05 |
---|---|
28 import com.oracle.truffle.api.frame.VirtualFrame; | 28 import com.oracle.truffle.api.frame.VirtualFrame; |
29 import com.oracle.truffle.api.nodes.NodeUtil; | 29 import com.oracle.truffle.api.nodes.NodeUtil; |
30 import com.oracle.truffle.api.nodes.RootNode; | 30 import com.oracle.truffle.api.nodes.RootNode; |
31 import com.oracle.truffle.api.source.Source; | 31 import com.oracle.truffle.api.source.Source; |
32 import com.oracle.truffle.api.source.SourceSection; | 32 import com.oracle.truffle.api.source.SourceSection; |
33 import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; | |
34 | |
33 import java.util.ArrayList; | 35 import java.util.ArrayList; |
34 import java.util.HashMap; | 36 import java.util.HashMap; |
35 import java.util.List; | 37 import java.util.List; |
36 import java.util.Map; | 38 import java.util.Map; |
39 | |
37 import static org.junit.Assert.assertEquals; | 40 import static org.junit.Assert.assertEquals; |
38 import static org.junit.Assert.assertNotNull; | 41 import static org.junit.Assert.assertNotNull; |
39 import static org.junit.Assert.assertSame; | 42 import static org.junit.Assert.assertSame; |
40 import static org.junit.Assert.assertTrue; | 43 import static org.junit.Assert.assertTrue; |
41 import static org.junit.Assert.fail; | 44 import static org.junit.Assert.fail; |
45 | |
46 import org.junit.After; | |
42 import org.junit.Before; | 47 import org.junit.Before; |
43 import org.junit.Test; | 48 import org.junit.Test; |
44 | 49 |
45 /** | 50 /** |
46 * <h3>Accessing the Truffle Runtime</h3> | 51 * <h3>Accessing the Truffle Runtime</h3> |
61 public class TruffleRuntimeTest { | 66 public class TruffleRuntimeTest { |
62 | 67 |
63 private TruffleRuntime runtime; | 68 private TruffleRuntime runtime; |
64 | 69 |
65 @Before | 70 @Before |
66 public void setUp() { | 71 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
72 InstrumentationTestMode.set(true); | |
67 this.runtime = Truffle.getRuntime(); | 73 this.runtime = Truffle.getRuntime(); |
74 } | |
75 | |
76 @After | |
77 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
78 InstrumentationTestMode.set(false); | |
68 } | 79 } |
69 | 80 |
70 private static RootNode createTestRootNode() { | 81 private static RootNode createTestRootNode() { |
71 return new RootNode(TestingLanguage.class, null, null) { | 82 return new RootNode(TestingLanguage.class, null, null) { |
72 @Override | 83 @Override |