comparison truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/ToolTestUtil.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 68a0c3dcea10
children 3c73d029b651
comparison
equal deleted inserted replaced
22240:f78c72e2e0b6 22241:14e6dfb1ef05
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.tools.test; 25 package com.oracle.truffle.tools.test;
26 26
27 import java.io.IOException; 27 import java.io.IOException;
28 import java.lang.reflect.InvocationTargetException;
29 import java.lang.reflect.Method;
30 28
31 import com.oracle.truffle.api.CallTarget; 29 import com.oracle.truffle.api.CallTarget;
32 import com.oracle.truffle.api.Truffle; 30 import com.oracle.truffle.api.Truffle;
33 import com.oracle.truffle.api.TruffleLanguage; 31 import com.oracle.truffle.api.TruffleLanguage;
34 import com.oracle.truffle.api.TruffleRuntime; 32 import com.oracle.truffle.api.TruffleRuntime;
321 @Override 319 @Override
322 public boolean isCloningAllowed() { 320 public boolean isCloningAllowed() {
323 return true; 321 return true;
324 } 322 }
325 323
326 @Override
327 public void applyInstrumentation() {
328 super.applyInstrumentation(body);
329 }
330 } 324 }
331 325
332 /** 326 /**
333 * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST 327 * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST
334 * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle 328 * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle
357 351
358 @Override 352 @Override
359 public boolean isCloningAllowed() { 353 public boolean isCloningAllowed() {
360 return true; 354 return true;
361 } 355 }
362 356 }
363 @Override
364 public void applyInstrumentation() {
365 Method method;
366 try {
367 method = Instrumenter.class.getDeclaredMethod("applyInstrumentation", Node.class);
368 method.setAccessible(true);
369 method.invoke(instrumenter, body);
370 } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
371 throw new RuntimeException("InstrumentationTestNodes");
372 }
373 }
374 }
375
376 } 357 }