Skip to content

Commit cda452d

Browse files
committed
WIP: add test case to assert if call graph has known edges.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent caf839d commit cda452d

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/main/java/com/ibm/cldk/utils/AnalysisUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ public static Iterable<Entrypoint> getEntryPoints(IClassHierarchy cha) {
198198
System.exit(1);
199199
return Stream.empty();
200200
}
201-
// TODO: Do we filter the entry points here?
202201
}).map(method -> new DefaultEntrypoint(method, cha)).collect(Collectors.toList());
203-
202+
// We're assuming that all methods are potential entrypoints. May revisit this later if the assumption is incorrect.
204203
Log.info("Registered " + entrypoints.size() + " entrypoints.");
205204
return entrypoints;
206205
}

src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class CodeAnalyzerIntegrationTest {
5151
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("build/libs")), "/opt/jars")
5252
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-corrupt-test")), "/test-applications/mvnw-corrupt-test")
5353
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/plantsbywebsphere")), "/test-applications/plantsbywebsphere")
54+
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/call-graph-test")), "/test-applications/call-graph-test")
5455
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-working-test")), "/test-applications/mvnw-working-test");
5556

5657
@Container
@@ -104,6 +105,23 @@ void shouldBeAbleToRunCodeAnalyzer() throws Exception {
104105
"Should have some output");
105106
}
106107

108+
@Test
109+
void callGraphShouldHaveKnownEdges() throws Exception {
110+
var runCodeAnalyzerOnCallGraphTest = container.withWorkingDirectory("/test-applications/call-graph-test")
111+
.execInContainer(
112+
"java",
113+
"-jar",
114+
String.format("/opt/jars/codeanalyzer-%s.jar", codeanalyzerVersion),
115+
"--input=/test-applications/call-graph-test",
116+
"--analysis-level=2",
117+
"--verbose"
118+
);
119+
120+
String output = runCodeAnalyzerOnCallGraphTest.getStdout();
121+
122+
// Normalize the output to ignore formatting differences
123+
String normalizedOutput = output.replaceAll("\\s+", "");
124+
}
107125
@Test
108126
void corruptMavenShouldNotBuildWithWrapper() throws IOException, InterruptedException {
109127
// Make executable

src/test/resources/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
generated/

src/test/resources/reference_analysis.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)