Skip to content

Commit

Permalink
Merge pull request #1132 from moshethebeadle/develop
Browse files Browse the repository at this point in the history
Make tests in Examples module runnable.
  • Loading branch information
swissiety authored Jan 6, 2025
2 parents f55a0ca + d0fdb3b commit d86d5bb
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/docguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
this enables that tutorial code can be tested and will fail if its not up to date anymore :)

```
{{ include('basicSetup/BasicSetup.java')}}
{{ include('basicSetup/BasicSetupTest.java')}}
```
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,22 @@
</dependency>

<!-- testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
11 changes: 10 additions & 1 deletion sootup.examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -55,6 +59,11 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/** This example illustrates how to create and use a new Soot Project. */
@Tag("Java8")
public class BasicSetup {
public class BasicSetupTest {

@Test
public void createByteCodeProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/** This example illustrates how to invoke body interceptors. */
@Tag("Java8")
public class BodyInterceptor {
public class BodyInterceptorTest {

@Test
public void test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import sootup.callgraph.CallGraph;
Expand All @@ -18,7 +19,7 @@
import sootup.java.core.views.JavaView;

@Tag("Java8")
public class CallgraphExample {
public class CallgraphExampleTest {

@Test
public void test() {
Expand Down Expand Up @@ -46,12 +47,16 @@ public void test() {

// Create type hierarchy and CHA
final ViewTypeHierarchy typeHierarchy = new ViewTypeHierarchy(view);
System.out.println(typeHierarchy.subclassesOf(classTypeA));
System.out.println("Subclasses of A: ");
typeHierarchy.subclassesOf(classTypeA).forEach(System.out::println);

CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(view);

// Create CG by initializing CHA with entry method(s)
CallGraph cg = cha.initialize(Collections.singletonList(entryMethodSignature));

cg.callsFrom(entryMethodSignature).forEach(System.out::println);
System.out.println("Call Graph from B:");
final Set<CallGraph.Call> calls = cg.callsFrom(entryMethodSignature);
calls.forEach(System.out::println);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* This code example will show you how to build and examine a class hierarchy using sootup.
*/
@Tag("Java8")
public class ClassHierarchy {
public class ClassHierarchyTest {

@Test
public void test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Bastian Haverkamp
*/
@Tag("Java8")
public class MutatingSootClass {
public class MutatingSootClassTest {

@Disabled
public void test() {
Expand Down

0 comments on commit d86d5bb

Please sign in to comment.