Skip to content

Commit

Permalink
Create new test class at each iteration. (#69)
Browse files Browse the repository at this point in the history
* Create new test class at each iteration.

* Format

* Add tests to JUnit plugin.
  • Loading branch information
aoli-al authored Dec 1, 2024
1 parent b639ab1 commit 1d17478
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {

allprojects {
group = "org.pastalab.fray"
version = "0.1.4-SNAPSHOT"
version = "0.1.6-SNAPSHOT"
}

repositories {
Expand Down
24 changes: 24 additions & 0 deletions junit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,28 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("org.junit.platform:junit-platform-engine:1.10.3")
implementation("org.junit.platform:junit-platform-commons:1.10.3")
testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
useJUnitPlatform {
includeEngines("junit-jupiter", "fray")
}
dependsOn(":instrumentation:jdk:build")
val instrumentationTask = evaluationDependsOn(":instrumentation:agent")
.tasks.named("shadowJar").get()
val jdk = project(":instrumentation:jdk")
val jvmti = project(":jvmti")
val instrumentation = instrumentationTask.outputs.files.first().absolutePath
classpath += tasks.named("jar").get().outputs.files + files(configurations.runtimeClasspath)
executable("${jdk.layout.buildDirectory.get().asFile}/java-inst/bin/java")
jvmArgs("-agentpath:${jvmti.layout.buildDirectory.get().asFile}/native-libs/libjvmti.so")
jvmArgs("-javaagent:$instrumentation")
jvmArgs("-ea")
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/java.util=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/java.io=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED")
}
9 changes: 6 additions & 3 deletions junit/src/main/kotlin/FrayTestExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ class FrayTestExecutor {

fun executeTest(request: ExecutionRequest, descriptor: MethodTestDescriptor) {
request.engineExecutionListener.executionStarted(descriptor)
val testInstance = descriptor.parent.testClass.getDeclaredConstructor().newInstance()
val testMethod = descriptor.testMethod
val workDir = createTempDirectory(WORK_DIR).absolutePathString()
val schedulerInfo = descriptor.getScheduler()
val config =
Configuration(
ExecutionInfo(
LambdaExecutor { testMethod.invoke(testInstance) },
LambdaExecutor {
val testInstance =
descriptor.parent.testClass.getDeclaredConstructor().newInstance()
val testMethod = descriptor.testMethod
testMethod.invoke(testInstance)
},
false,
true,
false,
Expand Down
22 changes: 22 additions & 0 deletions junit/src/test/java/DummyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import org.junit.jupiter.api.Test;
import org.pastalab.fray.junit.annotations.ConcurrencyTest;

public class DummyTest {
@Test
public void test() {
System.out.println("1");
}

@ConcurrencyTest
public void test2() {
System.out.println("2");
}

@ConcurrencyTest(
expectedException = AssertionError.class
)
public void test3() {
assert(false);
}

}

0 comments on commit 1d17478

Please sign in to comment.