Skip to content

Commit db004d2

Browse files
committed
feat: revert to only keep what is regarding code for the PluginAPI
1 parent 649ce56 commit db004d2

20 files changed

+88
-359
lines changed

Package.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ let package = Package(
1919
name: "SnapshotTestingPlugin",
2020
targets: ["SnapshotTestingPlugin"]
2121
),
22-
.library(
23-
name: "ImageSerializationPlugin",
24-
targets: ["ImageSerializationPlugin"]
25-
),
2622
.library(
2723
name: "InlineSnapshotTesting",
2824
targets: ["InlineSnapshotTesting"]
@@ -34,11 +30,6 @@ let package = Package(
3430
targets: [
3531
.target(
3632
name: "SnapshotTesting",
37-
dependencies: ["ImageSerializationPlugin"]
38-
),
39-
.target(name: "SnapshotTestingPlugin"),
40-
.target(
41-
name: "ImageSerializationPlugin",
4233
dependencies: ["SnapshotTestingPlugin"]
4334
),
4435
.target(

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ targets: [
230230
[available-strategies]: https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing/main/documentation/snapshottesting/snapshotting
231231
[defining-strategies]: https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing/main/documentation/snapshottesting/customstrategies
232232

233-
## Strategies / Plug-ins
233+
## Plug-ins
234234

235235
- [AccessibilitySnapshot](https://github.com/cashapp/AccessibilitySnapshot) adds easy regression
236236
testing for iOS accessibility.
@@ -273,18 +273,6 @@ targets: [
273273
- [SnapshotVision](https://github.com/gregersson/swift-snapshot-testing-vision) adds snapshot
274274
strategy for text recognition on views and images. Uses Apples Vision framework.
275275

276-
- [ImageSerializer HEIC](https://github.com/mackoj/swift-snapshot-testing-plugin-heic) make all the
277-
strategy that create image as output to store them in `.heic` storage format which reduces file sizes
278-
in comparison to PNG.
279-
280-
- [ImageSerializer WEBP](https://github.com/mackoj/swift-snapshot-testing-plugin-heic) make all the
281-
strategy that create image as output to store them in `.webp` storage format which reduces file sizes
282-
in comparison to PNG.
283-
284-
- [ImageSerializer JXL](https://github.com/mackoj/swift-snapshot-testing-plugin-heic) make all the
285-
strategy that create image as output to store them in `.jxl` storage format which reduces file sizes
286-
in comparison to PNG.
287-
288276
Have you written your own SnapshotTesting plug-in?
289277
[Add it here](https://github.com/pointfreeco/swift-snapshot-testing/edit/master/README.md) and
290278
submit a pull request!

Sources/ImageSerializationPlugin/ImageSerializationPlugin.swift

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

Sources/SnapshotTesting/AssertSnapshot.swift

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,11 @@
11
import XCTest
2-
import ImageSerializationPlugin
32

43
#if canImport(Testing)
54
// NB: We are importing only the implementation of Testing because that framework is not available
65
// in Xcode UI test targets.
76
@_implementationOnly import Testing
87
#endif
98

10-
/// Whether or not to change the default output image format to something else.
11-
@available(
12-
*,
13-
deprecated,
14-
message:
15-
"Use 'withSnapshotTesting' to customize the image output format. See the documentation for more information."
16-
)
17-
public var imageFormat: ImageSerializationFormat {
18-
get {
19-
_imageFormat
20-
}
21-
set { _imageFormat = newValue }
22-
}
23-
24-
@_spi(Internals)
25-
public var _imageFormat: ImageSerializationFormat {
26-
get {
27-
#if canImport(Testing)
28-
if let test = Test.current {
29-
for trait in test.traits.reversed() {
30-
if let diffTool = (trait as? _SnapshotsTestTrait)?.configuration.imageFormat {
31-
return diffTool
32-
}
33-
}
34-
}
35-
#endif
36-
return __imageFormat
37-
}
38-
set {
39-
__imageFormat = newValue
40-
}
41-
}
42-
43-
@_spi(Internals)
44-
public var __imageFormat: ImageSerializationFormat = .png
45-
46-
479
/// Enhances failure messages with a command line diff tool expression that can be copied and pasted
4810
/// into a terminal.
4911
@available(

Sources/SnapshotTesting/Plugins/ImageSerializer.swift

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

Sources/SnapshotTesting/SnapshotTestingConfiguration.swift

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import ImageSerializationPlugin
2-
31
/// Customizes `assertSnapshot` for the duration of an operation.
42
///
53
/// Use this operation to customize how the `assertSnapshot` function behaves in a test. It is most
@@ -28,14 +26,13 @@ import ImageSerializationPlugin
2826
public func withSnapshotTesting<R>(
2927
record: SnapshotTestingConfiguration.Record? = nil,
3028
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
31-
imageFormat: ImageSerializationFormat? = nil,
3229
operation: () throws -> R
3330
) rethrows -> R {
3431
try SnapshotTestingConfiguration.$current.withValue(
3532
SnapshotTestingConfiguration(
3633
record: record ?? SnapshotTestingConfiguration.current?.record ?? _record,
37-
diffTool: diffTool ?? SnapshotTestingConfiguration.current?.diffTool ?? SnapshotTesting._diffTool,
38-
imageFormat: imageFormat ?? SnapshotTestingConfiguration.current?.imageFormat ?? _imageFormat
34+
diffTool: diffTool ?? SnapshotTestingConfiguration.current?.diffTool
35+
?? SnapshotTesting._diffTool
3936
)
4037
) {
4138
try operation()
@@ -48,14 +45,12 @@ public func withSnapshotTesting<R>(
4845
public func withSnapshotTesting<R>(
4946
record: SnapshotTestingConfiguration.Record? = nil,
5047
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
51-
imageFormat: ImageSerializationFormat? = nil,
5248
operation: () async throws -> R
5349
) async rethrows -> R {
5450
try await SnapshotTestingConfiguration.$current.withValue(
5551
SnapshotTestingConfiguration(
5652
record: record ?? SnapshotTestingConfiguration.current?.record ?? _record,
57-
diffTool: diffTool ?? SnapshotTestingConfiguration.current?.diffTool ?? _diffTool,
58-
imageFormat: imageFormat ?? SnapshotTestingConfiguration.current?.imageFormat ?? _imageFormat
53+
diffTool: diffTool ?? SnapshotTestingConfiguration.current?.diffTool ?? _diffTool
5954
)
6055
) {
6156
try await operation()
@@ -76,17 +71,13 @@ public struct SnapshotTestingConfiguration: Sendable {
7671
///
7772
/// See ``Record-swift.struct`` for more information.
7873
public var record: Record?
79-
80-
public var imageFormat: ImageSerializationFormat?
8174

8275
public init(
8376
record: Record?,
84-
diffTool: DiffTool?,
85-
imageFormat: ImageSerializationFormat?
77+
diffTool: DiffTool?
8678
) {
8779
self.diffTool = diffTool
8880
self.record = record
89-
self.imageFormat = imageFormat
9081
}
9182

9283
/// The record mode of the snapshot test.

Sources/SnapshotTesting/SnapshotsTestTrait.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// NB: We are importing only the implementation of Testing because that framework is not available
33
// in Xcode UI test targets.
44
@_implementationOnly import Testing
5-
import ImageSerializationPlugin
65

76
@_spi(Experimental)
87
extension Trait where Self == _SnapshotsTestTrait {
@@ -13,14 +12,12 @@
1312
/// - diffTool: The diff tool to use in failure messages.
1413
public static func snapshots(
1514
record: SnapshotTestingConfiguration.Record? = nil,
16-
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
17-
imageFormat: ImageSerializationFormat? = nil
15+
diffTool: SnapshotTestingConfiguration.DiffTool? = nil
1816
) -> Self {
1917
_SnapshotsTestTrait(
2018
configuration: SnapshotTestingConfiguration(
2119
record: record,
22-
diffTool: diffTool,
23-
imageFormat: imageFormat
20+
diffTool: diffTool
2421
)
2522
)
2623
}

0 commit comments

Comments
 (0)