-
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.
Fix test hang and improve Fray gradle plugin. (#93)
- Loading branch information
Showing
17 changed files
with
119 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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 org.pastalab.fray.junit | ||
|
||
import java.nio.file.Paths | ||
|
||
object Common { | ||
val WORK_DIR = Paths.get(System.getProperty("fray.workDir", "build/fray/fray-report")) | ||
} |
9 changes: 9 additions & 0 deletions
9
junit/src/main/kotlin/org/pastalab/fray/junit/junit4/FrayRunner.kt
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,9 @@ | ||
package org.pastalab.fray.junit.junit4 | ||
|
||
import org.junit.runner.notification.RunNotifier | ||
import org.junit.runners.BlockJUnit4ClassRunner | ||
import org.junit.runners.model.FrameworkMethod | ||
|
||
class FrayRunner(clazz: Class<Any>) : BlockJUnit4ClassRunner(clazz) { | ||
override fun runChild(method: FrameworkMethod?, notifier: RunNotifier?) {} | ||
} |
2 changes: 1 addition & 1 deletion
2
junit/src/main/kotlin/FrayExtension.kt → ...stalab/fray/junit/junit5/FrayExtension.kt
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
2 changes: 1 addition & 1 deletion
2
junit/src/main/kotlin/FrayJupiterContext.kt → ...b/fray/junit/junit5/FrayJupiterContext.kt
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
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
2 changes: 1 addition & 1 deletion
2
.../main/kotlin/FrayTestInvocationContext.kt → ...junit/junit5/FrayTestInvocationContext.kt
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
2 changes: 1 addition & 1 deletion
2
...ain/kotlin/annotations/ConcurrencyTest.kt → ...nit/junit5/annotations/ConcurrencyTest.kt
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
54 changes: 54 additions & 0 deletions
54
junit/src/main/kotlin/org/pastalab/fray/junit/plain/FrayInTestLauncher.kt
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,54 @@ | ||
package org.pastalab.fray.junit.plain | ||
|
||
import java.io.File | ||
import kotlin.io.path.absolutePathString | ||
import kotlinx.serialization.json.Json | ||
import org.pastalab.fray.core.TestRunner | ||
import org.pastalab.fray.core.command.Configuration | ||
import org.pastalab.fray.core.command.ExecutionInfo | ||
import org.pastalab.fray.core.command.LambdaExecutor | ||
import org.pastalab.fray.core.randomness.ControlledRandom | ||
import org.pastalab.fray.core.scheduler.PCTScheduler | ||
import org.pastalab.fray.core.scheduler.Scheduler | ||
import org.pastalab.fray.junit.Common.WORK_DIR | ||
|
||
object FrayInTestLauncher { | ||
|
||
fun launchFray(runnable: Runnable, scheduler: Scheduler, randomnessProvider: ControlledRandom) { | ||
val config = | ||
Configuration( | ||
ExecutionInfo( | ||
LambdaExecutor( | ||
{ runnable.run() }, | ||
), | ||
false, | ||
false, | ||
-1), | ||
WORK_DIR.absolutePathString(), | ||
10000, | ||
60, | ||
scheduler, | ||
randomnessProvider, | ||
true, | ||
false, | ||
true, | ||
false, | ||
false, | ||
false, | ||
) | ||
val runner = TestRunner(config) | ||
runner.run()?.let { throw it } | ||
} | ||
|
||
fun launchFrayTest(test: Runnable) { | ||
launchFray(test, PCTScheduler(ControlledRandom(), 15, 0), ControlledRandom()) | ||
} | ||
|
||
fun launchFrayReplay(test: Runnable, path: String) { | ||
val randomPath = "${path}/random.json" | ||
val schedulerPath = "${path}/schedule.json" | ||
val randomnessProvider = Json.decodeFromString<ControlledRandom>(File(randomPath).readText()) | ||
val scheduler = Json.decodeFromString<Scheduler>(File(schedulerPath).readText()) | ||
launchFray(test, scheduler, randomnessProvider) | ||
} | ||
} |
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
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
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