-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add test to check determinism of runtime-index (#160)
- Loading branch information
1 parent
9eece8c
commit 92174b9
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...fingerprint/src/test/java/io/github/algomaster99/terminator/index/RuntimeIndexerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.github.algomaster99.terminator.index; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
public class RuntimeIndexerTest { | ||
|
||
@Test | ||
void runtimeIndexShouldBeDeterministic(@TempDir Path tempDir) throws IOException { | ||
// arrange | ||
Path indexFile = tempDir.resolve("r.json"); | ||
Path project = Path.of("src", "test", "resources", "runtime-index", "basic-math"); | ||
|
||
// act | ||
String[] jdk_argsFirst = {"jdk", "-o", indexFile.toString()}; | ||
Index.main(jdk_argsFirst); | ||
String[] runtime_argsFirst = { | ||
"runtime", "-p", project.toString(), "-i", indexFile.toString(), "-mj", "basic-math", "--cleanup" | ||
}; | ||
Index.main(runtime_argsFirst); | ||
String contentFirst = Files.readString(indexFile); | ||
|
||
String[] jdk_argsSecond = {"jdk", "-o", indexFile.toString()}; | ||
Index.main(jdk_argsSecond); | ||
String[] runtime_argsSecond = { | ||
"runtime", "-p", project.toString(), "-i", indexFile.toString(), "-mj", "basic-math", "--cleanup" | ||
}; | ||
Index.main(runtime_argsSecond); | ||
String contentSecond = Files.readString(indexFile); | ||
|
||
// assert | ||
assertThat(contentFirst).isEqualTo(contentSecond); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
classfile-fingerprint/src/test/resources/runtime-index/basic-math/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>basic-math</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.8.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
7 changes: 7 additions & 0 deletions
7
...-fingerprint/src/test/resources/runtime-index/basic-math/src/main/java/foo/BasicMath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package foo; | ||
|
||
public class BasicMath { | ||
public static int add(int x, int y) { | ||
return x + y; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...gerprint/src/test/resources/runtime-index/basic-math/src/test/java/foo/BasicMathTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package foo; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class BasicMathTest { | ||
@Test | ||
void test_add() { | ||
assertEquals(4, BasicMath.add(23,2)); | ||
} | ||
} |