Skip to content

Commit dd50a3a

Browse files
author
Jaroslav Tulach
committed
Prefix the test classes with Insight
1 parent e4f24f8 commit dd50a3a

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import org.graalvm.polyglot.HostAccess;
4949
import org.junit.Assert;
5050

51-
final class AgentObjectFactory extends ProxyLanguage {
51+
final class InsightObjectFactory extends ProxyLanguage {
5252
static TruffleObject insightObject;
5353

5454
static InsightAPI.OnConfig createConfig(
@@ -82,11 +82,11 @@ protected CallTarget parse(ParsingRequest request) throws Exception {
8282
@SuppressWarnings("try")
8383
public static Value createAgentObject(Context context) throws Exception {
8484
cleanAgentObject();
85-
ProxyLanguage.setDelegate(new AgentObjectFactory());
85+
ProxyLanguage.setDelegate(new InsightObjectFactory());
8686

8787
Value value;
8888

89-
try (AutoCloseable handle = Embedding.enableInsight(AgentObjectFactory.createAgentSource(), context)) {
89+
try (AutoCloseable handle = Embedding.enableInsight(InsightObjectFactory.createAgentSource(), context)) {
9090
value = context.eval(ProxyLanguage.ID, "");
9191
assertNotNull("Agent object has been initialized", insightObject);
9292
}
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage;
2828
import com.oracle.truffle.api.interop.InteropLibrary;
2929
import com.oracle.truffle.api.test.polyglot.ProxyLanguage;
30-
import static org.graalvm.tools.insight.test.AgentObjectFactory.createConfig;
30+
import static org.graalvm.tools.insight.test.InsightObjectFactory.createConfig;
3131
import java.net.URI;
3232
import java.util.Arrays;
3333
import java.util.LinkedList;
@@ -57,16 +57,16 @@
5757
import org.junit.Before;
5858
import org.junit.Test;
5959

60-
public class AgentObjectTest {
60+
public class InsightObjectTest {
6161
@Before
6262
public void cleanAgentObject() {
63-
AgentObjectFactory.cleanAgentObject();
63+
InsightObjectFactory.cleanAgentObject();
6464
}
6565

6666
@Test
6767
public void versionOfTheAgent() throws Exception {
68-
try (Context c = AgentObjectFactory.newContext()) {
69-
Value agent = AgentObjectFactory.createAgentObject(c);
68+
try (Context c = InsightObjectFactory.newContext()) {
69+
Value agent = InsightObjectFactory.createAgentObject(c);
7070
InsightAPI agentAPI = agent.as(InsightAPI.class);
7171
Assert.assertNotNull("Agent API obtained", agentAPI);
7272
assertEquals(Insight.VERSION, agentAPI.version());
@@ -75,16 +75,16 @@ public void versionOfTheAgent() throws Exception {
7575

7676
@Test
7777
public void versionOfTheAgentDirect() throws Exception {
78-
try (Context c = AgentObjectFactory.newContext()) {
79-
Value agent = AgentObjectFactory.createAgentObject(c);
78+
try (Context c = InsightObjectFactory.newContext()) {
79+
Value agent = InsightObjectFactory.createAgentObject(c);
8080
assertNotNull("agent created", agent);
81-
assertNotNull("we have agent's truffle object", AgentObjectFactory.insightObject);
81+
assertNotNull("we have agent's truffle object", InsightObjectFactory.insightObject);
8282

8383
InteropLibrary iop = InteropLibrary.getFactory().getUncached();
8484

85-
assertTrue("Yes, it has members", iop.hasMembers(AgentObjectFactory.insightObject));
85+
assertTrue("Yes, it has members", iop.hasMembers(InsightObjectFactory.insightObject));
8686

87-
Object members = iop.getMembers(AgentObjectFactory.insightObject);
87+
Object members = iop.getMembers(InsightObjectFactory.insightObject);
8888
long membersCount = iop.getArraySize(members);
8989
assertEquals(2, membersCount);
9090

@@ -95,8 +95,8 @@ public void versionOfTheAgentDirect() throws Exception {
9595

9696
@Test
9797
public void onErrorneousCallbackRegistration() throws Exception {
98-
try (Context c = AgentObjectFactory.newContext()) {
99-
Value agent = AgentObjectFactory.createAgentObject(c);
98+
try (Context c = InsightObjectFactory.newContext()) {
99+
Value agent = InsightObjectFactory.createAgentObject(c);
100100
InsightAPI agentAPI = agent.as(InsightAPI.class);
101101
Assert.assertNotNull("Agent API obtained", agentAPI);
102102

@@ -111,8 +111,8 @@ public void onErrorneousCallbackRegistration() throws Exception {
111111

112112
@Test
113113
public void onSourceCallback() throws Exception {
114-
try (Context c = AgentObjectFactory.newContext()) {
115-
Value agent = AgentObjectFactory.createAgentObject(c);
114+
try (Context c = InsightObjectFactory.newContext()) {
115+
Value agent = InsightObjectFactory.createAgentObject(c);
116116
InsightAPI agentAPI = agent.as(InsightAPI.class);
117117
Assert.assertNotNull("Agent API obtained", agentAPI);
118118

@@ -148,8 +148,8 @@ public void onSourceCallback() throws Exception {
148148

149149
@Test
150150
public void nullMimeType() throws Exception {
151-
try (Context c = AgentObjectFactory.newContext()) {
152-
Value agent = AgentObjectFactory.createAgentObject(c);
151+
try (Context c = InsightObjectFactory.newContext()) {
152+
Value agent = InsightObjectFactory.createAgentObject(c);
153153
InsightAPI agentAPI = agent.as(InsightAPI.class);
154154
Assert.assertNotNull("Agent API obtained", agentAPI);
155155

@@ -176,8 +176,8 @@ public void nullMimeType() throws Exception {
176176

177177
@Test
178178
public void onEnterCallback() throws Exception {
179-
try (Context c = AgentObjectFactory.newContext()) {
180-
Value agent = AgentObjectFactory.createAgentObject(c);
179+
try (Context c = InsightObjectFactory.newContext()) {
180+
Value agent = InsightObjectFactory.createAgentObject(c);
181181
InsightAPI agentAPI = agent.as(InsightAPI.class);
182182
Assert.assertNotNull("Agent API obtained", agentAPI);
183183

@@ -192,7 +192,7 @@ public void onEnterCallback() throws Exception {
192192
assertNull("No function entered yet", functionName[0]);
193193
functionName[0] = ctx.name();
194194
};
195-
agentAPI.on("enter", listener, AgentObjectFactory.createConfig(false, false, true, null, null));
195+
agentAPI.on("enter", listener, InsightObjectFactory.createConfig(false, false, true, null, null));
196196

197197
// @formatter:off
198198
Source sampleScript = Source.newBuilder(InstrumentationTestLanguage.ID,
@@ -245,7 +245,7 @@ public void evalFirstAndThenOnEnterCallbackInBackground() throws Throwable {
245245
}
246246

247247
private static void evalFirstAndThenOnEnterCallbackImpl(Executor registerIn) throws Throwable {
248-
try (Context c = AgentObjectFactory.newContext()) {
248+
try (Context c = InsightObjectFactory.newContext()) {
249249

250250
// @formatter:off
251251
Source sampleScript = Source.newBuilder(InstrumentationTestLanguage.ID,
@@ -260,7 +260,7 @@ private static void evalFirstAndThenOnEnterCallbackImpl(Executor registerIn) thr
260260
// @formatter:on
261261
c.eval(sampleScript);
262262

263-
Value agent = AgentObjectFactory.createAgentObject(c);
263+
Value agent = InsightObjectFactory.createAgentObject(c);
264264
InsightAPI agentAPI = agent.as(InsightAPI.class);
265265
Assert.assertNotNull("Agent API obtained", agentAPI);
266266

@@ -286,7 +286,7 @@ private static void evalFirstAndThenOnEnterCallbackImpl(Executor registerIn) thr
286286
Throwable[] err = {null};
287287
registerIn.execute(() -> {
288288
try {
289-
agentAPI.on("enter", listener, AgentObjectFactory.createConfig(false, false, true, null, null));
289+
agentAPI.on("enter", listener, InsightObjectFactory.createConfig(false, false, true, null, null));
290290
} catch (Throwable t) {
291291
err[0] = t;
292292
} finally {
@@ -315,16 +315,16 @@ private static void evalFirstAndThenOnEnterCallbackImpl(Executor registerIn) thr
315315
@Test
316316
public void onEnterCallbackWithFilterOnRootName() throws Exception {
317317
boolean[] finished = {false};
318-
try (Context c = AgentObjectFactory.newContext()) {
319-
Value agent = AgentObjectFactory.createAgentObject(c);
318+
try (Context c = InsightObjectFactory.newContext()) {
319+
Value agent = InsightObjectFactory.createAgentObject(c);
320320
InsightAPI agentAPI = agent.as(InsightAPI.class);
321321
Assert.assertNotNull("Agent API obtained", agentAPI);
322322

323323
String[] functionName = {null};
324324
agentAPI.on("enter", (ctx, frame) -> {
325325
assertNull("No function entered yet", functionName[0]);
326326
functionName[0] = ctx.name();
327-
}, AgentObjectFactory.createConfig(false, false, true, "foo", null));
327+
}, InsightObjectFactory.createConfig(false, false, true, "foo", null));
328328
agentAPI.on("close", () -> {
329329
finished[0] = true;
330330
});
@@ -356,8 +356,8 @@ public void onEnterCallbackWithFilterOnRootName() throws Exception {
356356
@Test
357357
public void onEnterCallbackWithFilterOnSourceName() throws Exception {
358358
boolean[] finished = {false};
359-
try (Context c = AgentObjectFactory.newContext()) {
360-
Value agent = AgentObjectFactory.createAgentObject(c);
359+
try (Context c = InsightObjectFactory.newContext()) {
360+
Value agent = InsightObjectFactory.createAgentObject(c);
361361
InsightAPI agentAPI = agent.as(InsightAPI.class);
362362
Assert.assertNotNull("Agent API obtained", agentAPI);
363363

@@ -368,7 +368,7 @@ public void onEnterCallbackWithFilterOnSourceName() throws Exception {
368368
}
369369
assertNull("No function entered yet", functionName[0]);
370370
functionName[0] = ctx.name();
371-
}, AgentObjectFactory.createConfig(false, false, true, null, new SourceNameCheck("foo.px")));
371+
}, InsightObjectFactory.createConfig(false, false, true, null, new SourceNameCheck("foo.px")));
372372
agentAPI.on("close", () -> {
373373
finished[0] = true;
374374
});
@@ -406,8 +406,8 @@ public void onEnterCallbackWithFilterOnSourceName() throws Exception {
406406

407407
@Test
408408
public void onStatementCallback() throws Exception {
409-
try (Context c = AgentObjectFactory.newContext()) {
410-
Value agent = AgentObjectFactory.createAgentObject(c);
409+
try (Context c = InsightObjectFactory.newContext()) {
410+
Value agent = InsightObjectFactory.createAgentObject(c);
411411
InsightAPI agentAPI = agent.as(InsightAPI.class);
412412
Assert.assertNotNull("Agent API obtained", agentAPI);
413413

@@ -416,7 +416,7 @@ public void onStatementCallback() throws Exception {
416416
Object index = frame.get("loopIndex0");
417417
assertTrue("Number as expected: " + index, index instanceof Number);
418418
loopIndexSum[0] += ((Number) index).intValue();
419-
}, AgentObjectFactory.createConfig(false, true, false, null, null));
419+
}, InsightObjectFactory.createConfig(false, true, false, null, null));
420420

421421
// @formatter:off
422422
Source sampleScript = Source.newBuilder(InstrumentationTestLanguage.ID,
@@ -437,19 +437,19 @@ public void onStatementCallback() throws Exception {
437437

438438
@Test
439439
public void onExpressionCallback() throws Exception {
440-
try (Context c = AgentObjectFactory.newContext()) {
441-
Value agent = AgentObjectFactory.createAgentObject(c);
440+
try (Context c = InsightObjectFactory.newContext()) {
441+
Value agent = InsightObjectFactory.createAgentObject(c);
442442
InsightAPI agentAPI = agent.as(InsightAPI.class);
443443
Assert.assertNotNull("Agent API obtained", agentAPI);
444444

445445
int[] expressionCounter = {0};
446446
int[] expressionReturnCounter = {0};
447447
agentAPI.on("enter", (ev, frame) -> {
448448
expressionCounter[0]++;
449-
}, AgentObjectFactory.createConfig(true, false, false, null, null));
449+
}, InsightObjectFactory.createConfig(true, false, false, null, null));
450450
agentAPI.on("return", (ev, frame) -> {
451451
expressionReturnCounter[0]++;
452-
}, AgentObjectFactory.createConfig(true, false, false, null, null));
452+
}, InsightObjectFactory.createConfig(true, false, false, null, null));
453453

454454
// @formatter:off
455455
Source sampleScript = Source.newBuilder(InstrumentationTestLanguage.ID,
@@ -472,8 +472,8 @@ public void onExpressionCallback() throws Exception {
472472
@Test
473473
public void internalScriptsAreIgnored() throws Exception {
474474
int[] closeCounter = {0};
475-
try (Context c = AgentObjectFactory.newContext()) {
476-
Value agent = AgentObjectFactory.createAgentObject(c);
475+
try (Context c = InsightObjectFactory.newContext()) {
476+
Value agent = InsightObjectFactory.createAgentObject(c);
477477
InsightAPI agentAPI = agent.as(InsightAPI.class);
478478
Assert.assertNotNull("Agent API obtained", agentAPI);
479479

@@ -499,10 +499,10 @@ public void internalScriptsAreIgnored() throws Exception {
499499
int[] expressionCounter = {0};
500500
agentAPI.on("enter", (ev, frame) -> {
501501
expressionCounter[0]++;
502-
}, AgentObjectFactory.createConfig(true, false, false, null, null));
502+
}, InsightObjectFactory.createConfig(true, false, false, null, null));
503503
agentAPI.on("return", (ev, frame) -> {
504504
expressionCounter[0]++;
505-
}, AgentObjectFactory.createConfig(true, false, false, null, null));
505+
}, InsightObjectFactory.createConfig(true, false, false, null, null));
506506

507507
agentAPI.on("close", () -> {
508508
closeCounter[0]++;
@@ -517,14 +517,14 @@ public void internalScriptsAreIgnored() throws Exception {
517517

518518
@Test
519519
public void onEnterAndReturn() throws Exception {
520-
try (Context c = AgentObjectFactory.newContext()) {
521-
Value agent = AgentObjectFactory.createAgentObject(c);
520+
try (Context c = InsightObjectFactory.newContext()) {
521+
Value agent = InsightObjectFactory.createAgentObject(c);
522522
InsightAPI agentAPI = agent.as(InsightAPI.class);
523523
Assert.assertNotNull("Agent API obtained", agentAPI);
524524

525525
String[][] max = {new String[0]};
526526
LinkedList<String> stack = new LinkedList<>();
527-
final InsightAPI.OnConfig allRoots = AgentObjectFactory.createConfig(false, false, true, null, null);
527+
final InsightAPI.OnConfig allRoots = InsightObjectFactory.createConfig(false, false, true, null, null);
528528
agentAPI.on("enter", (ev, frame) -> {
529529
stack.push(ev.name());
530530
if (stack.size() > max[0].length) {
@@ -563,8 +563,8 @@ public void onEnterAndReturn() throws Exception {
563563

564564
@Test
565565
public void accessFrameVariables() throws Exception {
566-
try (Context c = AgentObjectFactory.newContext()) {
567-
Value agent = AgentObjectFactory.createAgentObject(c);
566+
try (Context c = InsightObjectFactory.newContext()) {
567+
Value agent = InsightObjectFactory.createAgentObject(c);
568568
InsightAPI agentAPI = agent.as(InsightAPI.class);
569569
Assert.assertNotNull("Agent API obtained", agentAPI);
570570

@@ -609,7 +609,7 @@ public void accessFrameVariables() throws Exception {
609609
}
610610
}
611611
fail("Expecting an exception when setting unknown variable c");
612-
}, AgentObjectFactory.createConfig(true, false, false, "mul", null));
612+
}, InsightObjectFactory.createConfig(true, false, false, "mul", null));
613613

614614
Value mul = c.getBindings(InstrumentationTestLanguage.ID).getMember("mul");
615615
assertNotNull("mul function found", mul);

tools/src/org.graalvm.tools.insight.test/src/org/graalvm/tools/insight/test/NoSuchFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void noSuchFileDirectory() throws Exception {
4343
Assume.assumeFalse("File is missing", nonExisting.exists());
4444

4545
try (Context c = Context.newBuilder().allowIO(true).allowExperimentalOptions(true).option("agentscript", nonExisting.getAbsolutePath()).build()) {
46-
Object initializeTheAgent = AgentObjectFactory.createAgentObject(c);
46+
Object initializeTheAgent = InsightObjectFactory.createAgentObject(c);
4747
assertNotNull(initializeTheAgent);
4848
fail("Error: Expecting exception");
4949
} catch (PolyglotException t) {

0 commit comments

Comments
 (0)