Skip to content

Commit 4fb7694

Browse files
committed
Simplify snapshot test infrastructure
With only MinimizedSnapshotScipGenerator remaining, the abstraction layers became unnecessary: - Inline AggregateSnapshotGenerator into SaveSnapshots and delete it - Inline the abstract SnapshotSuite into its only subclass - Drop SnapshotHandler.withoutFinishedEvent (only used by the dropped aggregator) - Drop a dead onFinished override in MinimizedSnapshotScipGenerator
1 parent ceaa887 commit 4fb7694

5 files changed

Lines changed: 7 additions & 44 deletions

File tree

tests/snapshots/src/main/scala/tests/AggregateSnapshotGenerator.scala

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/snapshots/src/main/scala/tests/MinimizedSnapshotScipGenerator.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class MinimizedSnapshotScipGenerator extends SnapshotGenerator {
2020
val exit = ScipJava.app.run(args)
2121
require(exit == 0)
2222
}
23-
def onFinished(context: SnapshotContext): Unit = ()
2423
override def run(context: SnapshotContext, handler: SnapshotHandler): Unit = {
2524
onTargetroot(
2625
context,

tests/snapshots/src/main/scala/tests/SaveSnapshots.scala

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,11 @@ package tests
22

33
object SaveSnapshots {
44
def main(args: Array[String]): Unit = {
5-
val expectDirectory = tests.snapshots.BuildInfo.snapshotDirectory.toPath
6-
val mapping = Map(
7-
"minimized" -> new MinimizedSnapshotScipGenerator()
5+
val context = SnapshotContext(
6+
tests.snapshots.BuildInfo.snapshotDirectory.toPath
87
)
9-
10-
val enabledGenerators =
11-
if (args.isEmpty)
12-
mapping.values.toList
13-
else
14-
args.flatMap(mapping.get).toList
15-
16-
val generator = new AggregateSnapshotGenerator(enabledGenerators)
17-
18-
generator.run(SnapshotContext(expectDirectory), new SaveSnapshotHandler)
8+
val handler = new SaveSnapshotHandler
9+
new MinimizedSnapshotScipGenerator().run(context, handler)
10+
handler.onFinished(context)
1911
}
2012
}

tests/snapshots/src/main/scala/tests/SnapshotHandler.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,10 @@ package tests
33
import java.nio.file.Path
44

55
abstract class SnapshotHandler {
6-
self =>
76
def onSnapshotTest(
87
context: SnapshotContext,
98
expectFile: Path,
109
obtainedOutput: () => String
1110
): Unit = ()
1211
def onFinished(context: SnapshotContext): Unit = ()
13-
final def withoutFinishedEvent: SnapshotHandler =
14-
new SnapshotHandler {
15-
override def onFinished(context: SnapshotContext): Unit = () // Do nothing
16-
override def onSnapshotTest(
17-
context: SnapshotContext,
18-
expectFile: Path,
19-
obtainedOutput: () => String
20-
): Unit = {
21-
self.onSnapshotTest(context, expectFile, obtainedOutput)
22-
}
23-
}
2412
}

tests/snapshots/src/test/scala/tests/SnapshotSuite.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ package tests
22

33
import munit.FunSuite
44

5-
abstract class SnapshotSuite(generator: SnapshotGenerator)
6-
extends FunSuite
7-
with AssertSnapshotHandlers {
8-
generator.run(
5+
class MinimizedSnapshotScipSuite extends FunSuite with AssertSnapshotHandlers {
6+
new MinimizedSnapshotScipGenerator().run(
97
SnapshotContext(tests.snapshots.BuildInfo.snapshotDirectory.toPath),
108
new AssertSnapshotHandler
119
)
1210
}
13-
14-
class MinimizedSnapshotScipSuite
15-
extends SnapshotSuite(new MinimizedSnapshotScipGenerator)

0 commit comments

Comments
 (0)