Skip to content

Commit 952a4eb

Browse files
authored
Remove SelfieBound for taking selfies on weird threads and coroutines. (#213)
2 parents 28d277d + dce933f commit 952a4eb

File tree

1 file changed

+6
-26
lines changed
  • jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie

1 file changed

+6
-26
lines changed

jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/Selfie.kt

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,6 @@ import kotlin.io.encoding.ExperimentalEncodingApi
3232
import kotlin.jvm.JvmOverloads
3333
import kotlin.jvm.JvmStatic
3434

35-
/**
36-
* Used for creating snapshots which are independent of the thread or coroutine on which the test
37-
* started. See the [threading details](http://localhost:3000/jvm/kotest#threading-details) for more
38-
* info.
39-
*/
40-
class SelfieBound internal constructor(private val disk: DiskStorage) {
41-
fun <T> expectSelfie(actual: T, camera: Camera<T>) = expectSelfie(camera.snapshot(actual))
42-
fun expectSelfie(actual: String) = expectSelfie(Snapshot.of(actual))
43-
fun expectSelfie(actual: ByteArray) = expectSelfie(Snapshot.of(actual))
44-
fun expectSelfie(actual: Snapshot) = Selfie.DiskSelfie(actual, disk)
45-
fun preserveSelfiesOnDisk(vararg subsToKeep: String) {
46-
if (subsToKeep.isEmpty()) {
47-
disk.keep(null)
48-
} else {
49-
subsToKeep.forEach { disk.keep(it) }
50-
}
51-
}
52-
}
53-
5435
/** Static methods for creating snapshots. */
5536
object Selfie {
5637
internal val system: SnapshotSystem = initSnapshotSystem()
@@ -69,15 +50,14 @@ object Selfie {
6950
*/
7051
@JvmStatic
7152
fun preserveSelfiesOnDisk(vararg subsToKeep: String) {
72-
bind().preserveSelfiesOnDisk(*subsToKeep)
53+
val disk = system.diskThreadLocal()
54+
if (subsToKeep.isEmpty()) {
55+
disk.keep(null)
56+
} else {
57+
subsToKeep.forEach { disk.keep(it) }
58+
}
7359
}
7460

75-
/**
76-
* Used to bind to the currently executing test so that you can create disk selfies in other
77-
* threads and coroutines if you want.
78-
*/
79-
@JvmStatic fun bind() = SelfieBound(system.diskThreadLocal())
80-
8161
class DiskSelfie internal constructor(actual: Snapshot, val disk: DiskStorage) :
8262
LiteralStringSelfie(actual) {
8363
@JvmOverloads

0 commit comments

Comments
 (0)