Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.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 | 0d36601f233e |
comparison
equal
deleted
inserted
replaced
22240:f78c72e2e0b6 | 22241:14e6dfb1ef05 |
---|---|
25 import com.oracle.truffle.api.CallTarget; | 25 import com.oracle.truffle.api.CallTarget; |
26 import com.oracle.truffle.api.Truffle; | 26 import com.oracle.truffle.api.Truffle; |
27 import com.oracle.truffle.api.TruffleRuntime; | 27 import com.oracle.truffle.api.TruffleRuntime; |
28 import com.oracle.truffle.api.frame.VirtualFrame; | 28 import com.oracle.truffle.api.frame.VirtualFrame; |
29 import com.oracle.truffle.api.nodes.RootNode; | 29 import com.oracle.truffle.api.nodes.RootNode; |
30 import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; | |
31 | |
32 import org.junit.After; | |
30 import org.junit.Assert; | 33 import org.junit.Assert; |
34 import org.junit.Before; | |
31 import org.junit.Test; | 35 import org.junit.Test; |
32 | 36 |
33 /** | 37 /** |
34 * <h3>Creating a Root Node</h3> | 38 * <h3>Creating a Root Node</h3> |
35 * | 39 * |
48 * {@link com.oracle.truffle.api.test.ChildNodeTest}. | 52 * {@link com.oracle.truffle.api.test.ChildNodeTest}. |
49 * </p> | 53 * </p> |
50 */ | 54 */ |
51 public class RootNodeTest { | 55 public class RootNodeTest { |
52 | 56 |
57 @Before | |
58 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
59 InstrumentationTestMode.set(true); | |
60 } | |
61 | |
62 @After | |
63 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
64 InstrumentationTestMode.set(false); | |
65 } | |
66 | |
53 @Test | 67 @Test |
54 public void test() { | 68 public void test() { |
55 TruffleRuntime runtime = Truffle.getRuntime(); | 69 TruffleRuntime runtime = Truffle.getRuntime(); |
56 TestRootNode rootNode = new TestRootNode(); | 70 TestRootNode rootNode = new TestRootNode(); |
57 CallTarget target = runtime.createCallTarget(rootNode); | 71 CallTarget target = runtime.createCallTarget(rootNode); |