use of org.graalvm.compiler.options.OptionKey in project graal by oracle.
the class GraphResetDebugTest method test1.
@SuppressWarnings("try")
@Test
public void test1() {
EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
// Configure with an option that enables scopes
map.put(DebugOptions.DumpOnError, true);
DebugContext debug = getDebugContext(new OptionValues(map));
StructuredGraph graph = parseEager("testSnippet", AllowAssumptions.YES, debug);
boolean resetSucceeded = false;
try (Scope scope = debug.scope("some scope")) {
graph.resetDebug(DebugContext.DISABLED);
resetSucceeded = true;
} catch (AssertionError expected) {
}
Assert.assertFalse(resetSucceeded);
}
use of org.graalvm.compiler.options.OptionKey in project graal by oracle.
the class DebugContextTest method testEnabledSandbox.
@Test
public void testEnabledSandbox() {
EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
// Configure with an option that enables scopes
map.put(DebugOptions.DumpOnError, true);
OptionValues options = new OptionValues(map);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DebugContext debug = DebugContext.create(options, NO_DESCRIPTION, NO_GLOBAL_METRIC_VALUES, new PrintStream(baos), DebugHandlersFactory.LOADER);
Exception e = new Exception("testEnabledSandbox");
String scopeName = "";
try {
try (DebugContext.Scope d = debug.sandbox("TestExceptionHandling", debug.getConfig())) {
scopeName = d.getQualifiedName();
throw e;
} catch (Throwable t) {
assert e == t;
debug.handle(t);
}
} catch (Throwable t) {
// The exception object should propagate all the way out through
// a enabled sandbox scope
Assert.assertEquals(e, t);
}
String logged = baos.toString();
String expected = String.format("Exception raised in scope %s: %s", scopeName, e);
String line = "-------------------------------------------------------";
Assert.assertTrue(String.format("Could not find \"%s\" in content between lines below:%n%s%n%s%s", expected, line, logged, line), logged.contains(expected));
}
Aggregations