Skip to content

Commit 73fc5b0

Browse files
committed
feat: add Gradle build configuration and update versioning
1 parent 4e2197e commit 73fc5b0

5 files changed

Lines changed: 103 additions & 28 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __pycache__/
1010
# Distribution / packaging
1111
.Python
1212
build/
13+
.gradle/
1314
develop-eggs/
1415
cli/dist/
1516
downloads/
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
plugins {
2+
java
3+
id("com.gradleup.shadow") version "9.0.0-beta12"
4+
}
5+
6+
group = "com.codeflash"
7+
version = "1.0.0"
8+
9+
java {
10+
sourceCompatibility = JavaVersion.VERSION_11
11+
targetCompatibility = JavaVersion.VERSION_11
12+
}
13+
14+
repositories {
15+
mavenCentral()
16+
}
17+
18+
dependencies {
19+
implementation("com.google.code.gson:gson:2.10.1")
20+
implementation("com.esotericsoftware:kryo:5.6.2")
21+
implementation("org.objenesis:objenesis:3.4")
22+
implementation("org.xerial:sqlite-jdbc:3.45.0.0")
23+
implementation("org.ow2.asm:asm:9.7.1")
24+
implementation("org.ow2.asm:asm-commons:9.7.1")
25+
26+
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
27+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
28+
}
29+
30+
tasks.test {
31+
useJUnitPlatform()
32+
jvmArgs(
33+
"--add-opens", "java.base/java.util=ALL-UNNAMED",
34+
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
35+
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
36+
"--add-opens", "java.base/java.math=ALL-UNNAMED",
37+
"--add-opens", "java.base/java.io=ALL-UNNAMED",
38+
"--add-opens", "java.base/java.net=ALL-UNNAMED",
39+
"--add-opens", "java.base/java.time=ALL-UNNAMED",
40+
)
41+
}
42+
43+
tasks.shadowJar {
44+
archiveBaseName.set("codeflash-runtime")
45+
archiveVersion.set("1.0.0")
46+
archiveClassifier.set("")
47+
48+
relocate("org.objectweb.asm", "com.codeflash.asm")
49+
50+
manifest {
51+
attributes(
52+
"Main-Class" to "com.codeflash.Comparator",
53+
"Premain-Class" to "com.codeflash.profiler.ProfilerAgent",
54+
"Can-Retransform-Classes" to "true",
55+
)
56+
}
57+
58+
exclude("META-INF/*.SF")
59+
exclude("META-INF/*.DSA")
60+
exclude("META-INF/*.RSA")
61+
}
62+
63+
tasks.build {
64+
dependsOn(tasks.shadowJar)
65+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "codeflash-runtime"

codeflash-java-runtime/src/test/java/com/codeflash/ComparatorCorrectnessTest.java

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ void testAllPlaceholderSkips() throws Exception {
5454
KryoPlaceholder.create(new Object(), "unserializable", "root")
5555
);
5656

57-
insertRow(originalDb, "iter_1_0", 1, placeholderBytes);
58-
insertRow(candidateDb, "iter_1_1", 1, placeholderBytes);
57+
insertRow(originalDb, 1, 1, placeholderBytes);
58+
insertRow(candidateDb, 1, 1, placeholderBytes);
5959

6060
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
6161
Map<String, Object> result = parseJson(json);
@@ -74,8 +74,8 @@ void testDeserializationErrorSkipped() throws Exception {
7474
// Insert corrupted byte data that will fail Kryo deserialization
7575
byte[] corruptedBytes = new byte[]{0x01, 0x02, 0x03, (byte) 0xFF, (byte) 0xFE};
7676

77-
insertRow(originalDb, "iter_1_0", 1, corruptedBytes);
78-
insertRow(candidateDb, "iter_1_1", 1, corruptedBytes);
77+
insertRow(originalDb, 1, 1, corruptedBytes);
78+
insertRow(candidateDb, 1, 1, corruptedBytes);
7979

8080
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
8181
Map<String, Object> result = parseJson(json);
@@ -97,12 +97,12 @@ void testMixedRealAndPlaceholder() throws Exception {
9797
KryoPlaceholder.create(new Object(), "unserializable", "root")
9898
);
9999

100-
insertRow(originalDb, "iter_1_0", 1, realBytes1);
101-
insertRow(candidateDb, "iter_1_1", 1, realBytes1);
102-
insertRow(originalDb, "iter_2_0", 1, realBytes2);
103-
insertRow(candidateDb, "iter_2_1", 1, realBytes2);
104-
insertRow(originalDb, "iter_3_0", 1, placeholderBytes);
105-
insertRow(candidateDb, "iter_3_1", 1, placeholderBytes);
100+
insertRow(originalDb, 1, 1, realBytes1);
101+
insertRow(candidateDb, 1, 1, realBytes1);
102+
insertRow(originalDb, 2, 1, realBytes2);
103+
insertRow(candidateDb, 2, 1, realBytes2);
104+
insertRow(originalDb, 3, 1, placeholderBytes);
105+
insertRow(candidateDb, 3, 1, placeholderBytes);
106106

107107
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
108108
Map<String, Object> result = parseJson(json);
@@ -121,10 +121,10 @@ void testNormalHappyPath() throws Exception {
121121
byte[] bytes1 = Serializer.serialize(100);
122122
byte[] bytes2 = Serializer.serialize("world");
123123

124-
insertRow(originalDb, "iter_1_0", 1, bytes1);
125-
insertRow(candidateDb, "iter_1_1", 1, bytes1);
126-
insertRow(originalDb, "iter_2_0", 1, bytes2);
127-
insertRow(candidateDb, "iter_2_1", 1, bytes2);
124+
insertRow(originalDb, 1, 1, bytes1);
125+
insertRow(candidateDb, 1, 1, bytes1);
126+
insertRow(originalDb, 2, 1, bytes2);
127+
insertRow(candidateDb, 2, 1, bytes2);
128128

129129
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
130130
Map<String, Object> result = parseJson(json);
@@ -144,8 +144,8 @@ void testNormalMismatch() throws Exception {
144144
byte[] origBytes = Serializer.serialize(42);
145145
byte[] candBytes = Serializer.serialize(99);
146146

147-
insertRow(originalDb, "iter_1_0", 1, origBytes);
148-
insertRow(candidateDb, "iter_1_1", 1, candBytes);
147+
insertRow(originalDb, 1, 1, origBytes);
148+
insertRow(candidateDb, 1, 1, candBytes);
149149

150150
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
151151
Map<String, Object> result = parseJson(json);
@@ -161,8 +161,8 @@ void testVoidMethodsBothNull() throws Exception {
161161
createTestDb(candidateDb);
162162

163163
// Insert rows with NULL return_value (void methods)
164-
insertRow(originalDb, "iter_1_0", 1, null);
165-
insertRow(candidateDb, "iter_1_1", 1, null);
164+
insertRow(originalDb, 1, 1, null);
165+
insertRow(candidateDb, 1, 1, null);
166166

167167
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
168168
Map<String, Object> result = parseJson(json);
@@ -178,7 +178,7 @@ void testOneSideEmpty() throws Exception {
178178
createTestDb(candidateDb);
179179

180180
byte[] bytes = Serializer.serialize(42);
181-
insertRow(originalDb, "iter_1_0", 1, bytes);
181+
insertRow(originalDb, 1, 1, bytes);
182182
// candidateDb has no rows
183183

184184
String json = Comparator.compareDatabases(originalDb.toString(), candidateDb.toString());
@@ -216,21 +216,29 @@ private void createTestDb(Path dbPath) throws Exception {
216216
try (Connection conn = DriverManager.getConnection(url);
217217
Statement stmt = conn.createStatement()) {
218218
stmt.execute("CREATE TABLE IF NOT EXISTS test_results ("
219-
+ "iteration_id TEXT NOT NULL, "
220-
+ "loop_index INTEGER NOT NULL, "
219+
+ "test_module_path TEXT, "
220+
+ "test_class_name TEXT, "
221+
+ "test_function_name TEXT, "
222+
+ "function_getting_tested TEXT, "
223+
+ "loop_index INTEGER, "
224+
+ "iteration_id INTEGER, "
225+
+ "runtime INTEGER, "
221226
+ "return_value BLOB, "
222-
+ "PRIMARY KEY (iteration_id, loop_index))");
227+
+ "verification_type TEXT)");
223228
}
224229
}
225230

226-
private void insertRow(Path dbPath, String iterationId, int loopIndex, byte[] returnValue) throws Exception {
231+
private void insertRow(Path dbPath, int iterationId, int loopIndex, byte[] returnValue) throws Exception {
227232
String url = "jdbc:sqlite:" + dbPath;
228233
try (Connection conn = DriverManager.getConnection(url);
229234
PreparedStatement ps = conn.prepareStatement(
230-
"INSERT INTO test_results (iteration_id, loop_index, return_value) VALUES (?, ?, ?)")) {
231-
ps.setString(1, iterationId);
232-
ps.setInt(2, loopIndex);
233-
ps.setBytes(3, returnValue);
235+
"INSERT INTO test_results (test_module_path, test_class_name, test_function_name, iteration_id, loop_index, return_value) VALUES (?, ?, ?, ?, ?, ?)")) {
236+
ps.setString(1, "com.example");
237+
ps.setString(2, "TestClass");
238+
ps.setString(3, "testMethod");
239+
ps.setInt(4, iterationId);
240+
ps.setInt(5, loopIndex);
241+
ps.setBytes(6, returnValue);
234242
ps.executeUpdate();
235243
}
236244
}

codeflash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These version placeholders will be replaced by uv-dynamic-versioning during build.
2-
__version__ = "0.20.1.post570.dev0+0fb5e36b"
2+
__version__ = "0.20.1.post848.dev0+f4a4ac63"

0 commit comments

Comments
 (0)