Skip to content

Commit 33d94fb

Browse files
committed
Adding package swift interface type tests
1 parent 99f3c46 commit 33d94fb

File tree

3 files changed

+491
-8
lines changed

3 files changed

+491
-8
lines changed

Package.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,15 @@ let package = Package(
140140
"public-api-diff"
141141
],
142142
resources: [
143-
// Copy Tests/ExampleTests/Resources directories as-is.
144-
// Use to retain directory structure.
145-
// Will be at top level in bundle.
146143
.copy("Resources/expected-reference-changes.md")
147144
]
148145
),
149146
.testTarget(
150147
name: "IntegrationTests",
151148
dependencies: ["public-api-diff"],
152149
resources: [
153-
// Copy Tests/ExampleTests/Resources directories as-is.
154-
// Use to retain directory structure.
155-
// Will be at top level in bundle.
156150
.copy("Resources/expected-reference-changes-swift-interface-private.md"),
151+
.copy("Resources/expected-reference-changes-swift-interface-package.md"),
157152
.copy("Resources/expected-reference-changes-swift-interface-public.md")
158153
]
159154
)

Tests/IntegrationTests/ReferencePackageTests.swift

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ReferencePackageTests: XCTestCase {
5050
try? FileManager.default.removeItem(at: newReferencePackageDirectory)
5151
}
5252

53-
func test_swiftInterface_public() async throws {
53+
func test_swiftInterfaceType_public() async throws {
5454

5555
let interfaceType: InterfaceType = .public
5656

@@ -75,8 +75,36 @@ class ReferencePackageTests: XCTestCase {
7575
}
7676
}
7777
}
78+
79+
func test_swiftInterfaceType_package() async throws {
7880

79-
func test_swiftInterface_private() async throws {
81+
let interfaceType: InterfaceType = .package
82+
83+
let expectedOutput = try expectedOutput(for: interfaceType)
84+
let pipelineOutput = try await runPipeline(for: interfaceType)
85+
86+
let markdownOutput = MarkdownOutputGenerator().generate(
87+
from: pipelineOutput,
88+
allTargets: ["ReferencePackage"],
89+
oldVersionName: "old_package",
90+
newVersionName: "new_package",
91+
warnings: []
92+
)
93+
94+
let expectedLines = sanitizeOutput(expectedOutput).components(separatedBy: "\n")
95+
let markdownOutputLines = sanitizeOutput(markdownOutput).components(separatedBy: "\n")
96+
97+
print(markdownOutput)
98+
99+
for i in 0..<expectedLines.count {
100+
if expectedLines[i] != markdownOutputLines[i] {
101+
XCTAssertEqual(expectedLines[i], markdownOutputLines[i])
102+
return
103+
}
104+
}
105+
}
106+
107+
func test_swiftInterfaceType_private() async throws {
80108

81109
let interfaceType: InterfaceType = .private
82110

@@ -117,12 +145,15 @@ private extension ReferencePackageTests {
117145

118146
enum InterfaceType {
119147
case `public`
148+
case `package`
120149
case `private`
121150

122151
var expectedOutputFileName: String {
123152
switch self {
124153
case .public:
125154
"expected-reference-changes-swift-interface-public"
155+
case .package:
156+
"expected-reference-changes-swift-interface-package"
126157
case .private:
127158
"expected-reference-changes-swift-interface-private"
128159
}
@@ -132,6 +163,8 @@ private extension ReferencePackageTests {
132163
switch self {
133164
case .public:
134165
"\(XcodeTools.Constants.derivedDataPath)/Build/Products/Debug-iphoneos/ReferencePackage.swiftmodule/arm64-apple-ios.swiftinterface"
166+
case .package:
167+
"\(XcodeTools.Constants.derivedDataPath)/Build/Products/Debug-iphoneos/ReferencePackage.swiftmodule/arm64-apple-ios.package.swiftinterface"
135168
case .private:
136169
"\(XcodeTools.Constants.derivedDataPath)/Build/Products/Debug-iphoneos/ReferencePackage.swiftmodule/arm64-apple-ios.private.swiftinterface"
137170
}

0 commit comments

Comments
 (0)