Skip to content

Commit 8502f73

Browse files
authored
Add additional canImport checks to AttachmentTests.swift (#1244)
This PR adds more `canImport` checks to `AttachmentTests` so that, if we're not building e.g. `_Testing_AppKit`, the file still compiles. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 4c5f9a4 commit 8502f73

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Tests/TestingTests/AttachmentTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010

1111
@testable @_spi(ForToolsIntegrationOnly) import Testing
1212
private import _TestingInternals
13-
#if canImport(AppKit)
13+
#if canImport(AppKit) && canImport(_Testing_AppKit)
1414
import AppKit
1515
@_spi(Experimental) import _Testing_AppKit
1616
#endif
17-
#if canImport(Foundation)
17+
#if canImport(Foundation) && canImport(_Testing_Foundation)
1818
import Foundation
1919
import _Testing_Foundation
2020
#endif
21-
#if canImport(CoreGraphics)
21+
#if canImport(CoreGraphics) && canImport(_Testing_CoreGraphics)
2222
import CoreGraphics
2323
@_spi(Experimental) import _Testing_CoreGraphics
2424
#endif
25-
#if canImport(CoreImage)
25+
#if canImport(CoreImage) && canImport(_Testing_CoreImage)
2626
import CoreImage
2727
@_spi(Experimental) import _Testing_CoreImage
2828
#endif
29-
#if canImport(UIKit)
29+
#if canImport(UIKit) && canImport(_Testing_UIKit)
3030
import UIKit
3131
@_spi(Experimental) import _Testing_UIKit
3232
#endif
@@ -259,7 +259,7 @@ struct AttachmentTests {
259259
}
260260
}
261261

262-
#if canImport(Foundation)
262+
#if canImport(Foundation) && canImport(_Testing_Foundation)
263263
#if !SWT_NO_FILE_IO
264264
@Test func attachContentsOfFileURL() async throws {
265265
let data = try #require("<!doctype html>".data(using: .utf8))
@@ -481,7 +481,7 @@ extension AttachmentTests {
481481
try test(value)
482482
}
483483

484-
#if canImport(Foundation)
484+
#if canImport(Foundation) && canImport(_Testing_Foundation)
485485
@Test func data() throws {
486486
let value = try #require("abc123".data(using: .utf8))
487487
try test(value)
@@ -499,7 +499,7 @@ extension AttachmentTests {
499499
case couldNotCreateCGImage
500500
}
501501

502-
#if canImport(CoreGraphics)
502+
#if canImport(CoreGraphics) && canImport(_Testing_CoreGraphics)
503503
static let cgImage = Result<CGImage, any Error> {
504504
let size = CGSize(width: 32.0, height: 32.0)
505505
let rgb = CGColorSpaceCreateDeviceRGB()
@@ -606,7 +606,7 @@ extension AttachmentTests {
606606
}
607607
#endif
608608

609-
#if canImport(CoreImage)
609+
#if canImport(CoreImage) && canImport(_Testing_CoreImage)
610610
@available(_uttypesAPI, *)
611611
@Test func attachCIImage() throws {
612612
let image = CIImage(cgImage: try Self.cgImage.get())
@@ -618,7 +618,7 @@ extension AttachmentTests {
618618
}
619619
#endif
620620

621-
#if canImport(AppKit)
621+
#if canImport(AppKit) && canImport(_Testing_AppKit)
622622
static var nsImage: NSImage {
623623
get throws {
624624
let cgImage = try cgImage.get()
@@ -683,7 +683,7 @@ extension AttachmentTests {
683683
}
684684
#endif
685685

686-
#if canImport(UIKit)
686+
#if canImport(UIKit) && canImport(_Testing_UIKit)
687687
@available(_uttypesAPI, *)
688688
@Test func attachUIImage() throws {
689689
let image = UIImage(cgImage: try Self.cgImage.get())
@@ -742,7 +742,7 @@ struct MySendableAttachableWithDefaultByteCount: Attachable, Sendable {
742742
}
743743
}
744744

745-
#if canImport(Foundation)
745+
#if canImport(Foundation) && canImport(_Testing_Foundation)
746746
struct MyCodableAttachable: Codable, Attachable, Sendable {
747747
var string: String
748748
}
@@ -784,7 +784,7 @@ final class MyCodableAndSecureCodingAttachable: NSObject, Codable, NSSecureCodin
784784
}
785785
#endif
786786

787-
#if canImport(AppKit)
787+
#if canImport(AppKit) && canImport(_Testing_AppKit)
788788
private final class MyImage: NSImage {
789789
override init(size: NSSize) {
790790
super.init(size: size)

0 commit comments

Comments
 (0)