Skip to content

Commit e952579

Browse files
committed
[test] Add a test that combines all TBD files into a single module.
This checks that all combinations of optimized & non-optimized, and whole-module optimization & incremental compilation give the same result, on a module where this is actually interesting (i.e. has multiple files so the behaviour differs between the two).
1 parent e57b332 commit e952579

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed

test/TBD/Inputs/extension_types.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
public protocol Foreign {
1+
public protocol ExtensionForeign {
22
func foreignMethod()
33
var foreignGet: Int { get }
44
var foreignGetSet: Int { get set }
55
}
6-
public protocol ForeignInherit: Foreign {}
7-
extension ForeignInherit {
6+
public protocol ExtensionForeignInherit: ExtensionForeign {}
7+
extension ExtensionForeignInherit {
88
public func foreignMethod() {}
99
public var foreignGet: Int { return 0 }
1010
public var foreignGetSet: Int {

test/TBD/all-in-one.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t)
3+
4+
// RUN: %gyb %S/class_objc.swift.gyb > %t/class_objc.swift
5+
// RUN: %gyb %S/extension.swift.gyb > %t/extension.swift
6+
// RUN: %gyb %S/subclass.swift.gyb > %t/subclass.swift
7+
8+
// RUN: %target-build-swift %S/Inputs/extension_types.swift -module-name ExtensionTypes -emit-module -emit-module-path %t/ExtensionTypes.swiftmodule
9+
// RUN: %target-build-swift %S/Inputs/subclass_super.swift -emit-library -emit-module -o %t/subclass_super.%target-dylib-extension -Xfrontend -enable-resilience
10+
11+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/incremental_Onone.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module
12+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/wmo_Onone.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -wmo
13+
14+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/incremental_O.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -O
15+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/wmo_O.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -wmo -O
16+
17+
// RUN: diff %t/incremental_Onone.tbd %t/wmo_Onone.tbd
18+
// RUN: diff %t/incremental_O.tbd %t/wmo_O.tbd
19+
// RUN: diff %t/incremental_Onone.tbd %t/incremental_O.tbd
20+
21+
// REQUIRES: objc_interop

test/TBD/extension.swift.gyb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ def conformanceBody(protocol):
6363
% for name in local_decl_names:
6464
% access = name.lower()
6565

66-
${access} protocol ${name} {
66+
${access} protocol Extension${name} {
6767
func ${access}Method()
6868
var ${access}Get: Int { get }
6969
var ${access}GetSet: Int { get set }
7070
}
7171

7272
// Defaulted methods:
73-
${access} protocol ${name}Inherit: Foreign {}
74-
extension ${name}Inherit {
73+
${access} protocol Extension${name}Inherit: ExtensionForeign {}
74+
extension Extension${name}Inherit {
7575
${conformanceBody(name)}
7676
}
7777

@@ -86,21 +86,21 @@ ${access} struct ${name}StructOneExtension {}
8686

8787
% for pname in all_decl_names:
8888
// e.g. extension PublicStruct: Private { ... }
89-
extension ${sname}Struct: ${pname} {
89+
extension ${sname}Struct: Extension${pname} {
9090
${conformanceBody(pname)}
9191
}
9292

9393
// e.g. extension PublicStructInherit: PrivateInherit {}
94-
extension ${sname}StructInherit: ${pname}Inherit {}
94+
extension ${sname}StructInherit: Extension${pname}Inherit {}
9595

9696
// e.g. extension PublicStructInheritNoDefault: PrivateInherit { ... }
97-
extension ${sname}StructInheritNoDefault: ${pname}Inherit {
97+
extension ${sname}StructInheritNoDefault: Extension${pname}Inherit {
9898
${conformanceBody(pname)}
9999
}
100100
% end
101101

102-
// e.g. extension PublicStructOneExtension: Foreign, Public, Internal, Private { ... }
103-
extension ${sname}StructOneExtension: ${", ".join(p for p in all_decl_names)} {
102+
// e.g. extension PublicStructOneExtension: ExtensionForeign, ExtensionPublic, ExtensionInternal, ExtensionPrivate { ... }
103+
extension ${sname}StructOneExtension: ${", ".join("Extension" + p for p in all_decl_names)} {
104104
% for pname in all_decl_names:
105105
${conformanceBody(pname)}
106106
% end

test/TBD/struct.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all %s -enable-testing -O
88
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all %s -enable-resilience -enable-testing -O
99

10-
public struct PublicNothing {}
10+
public struct StructPublicNothing {}
1111

12-
public struct PublicInit {
12+
public struct StructPublicInit {
1313
public init() {}
1414

1515
public init(public_: Int) {}
1616
internal init(internal_: Int) {}
1717
private init(private_: Int) {}
1818
}
1919

20-
public struct PublicMethods {
20+
public struct StructPublicMethods {
2121
public init() {}
2222
public func publicMethod() {}
2323
internal func internalMethod() {}
2424
private func privateMethod() {}
2525
}
2626

27-
public struct PublicProperties {
27+
public struct StructPublicProperties {
2828
public let publicLet: Int = 0
2929
internal let internalLet: Int = 0
3030
private let privateLet: Int = 0
@@ -51,7 +51,7 @@ public struct PublicProperties {
5151
}
5252
}
5353

54-
public struct PublicSubscripts {
54+
public struct StructPublicSubscripts {
5555
public subscript(publicGet _: Int) -> Int { return 0 }
5656
internal subscript(internalGet _: Int) -> Int { return 0 }
5757
private subscript(privateGet _: Int) -> Int { return 0 }
@@ -70,7 +70,7 @@ public struct PublicSubscripts {
7070
}
7171
}
7272

73-
public struct PublicStatics {
73+
public struct StructPublicStatics {
7474
public static func publicStaticFunc() {}
7575
internal static func internalStaticFunc() {}
7676
private static func privateStaticFunc() {}
@@ -101,7 +101,7 @@ public struct PublicStatics {
101101
}
102102
}
103103

104-
public struct PublicGeneric<T, U, V> {
104+
public struct StructPublicGeneric<T, U, V> {
105105
public var publicVar: T
106106
internal var internalVar: U
107107
private var privateVar: V
@@ -126,22 +126,22 @@ public struct PublicGeneric<T, U, V> {
126126
}
127127

128128

129-
internal struct InternalNothing {}
129+
internal struct StructInternalNothing {}
130130

131-
internal struct InternalInit {
131+
internal struct StructInternalInit {
132132
internal init() {}
133133

134134
internal init(internal_: Int) {}
135135
private init(private_: Int) {}
136136
}
137137

138-
internal struct InternalMethods {
138+
internal struct StructInternalMethods {
139139
internal init() {}
140140
internal func internalMethod() {}
141141
private func privateMethod() {}
142142
}
143143

144-
internal struct InternalProperties {
144+
internal struct StructInternalProperties {
145145
internal let internalLet: Int = 0
146146
private let privateLet: Int = 0
147147

@@ -161,7 +161,7 @@ internal struct InternalProperties {
161161
}
162162
}
163163

164-
internal struct InternalSubscripts {
164+
internal struct StructInternalSubscripts {
165165
internal subscript(internalGet _: Int) -> Int { return 0 }
166166
private subscript(privateGet _: Int) -> Int { return 0 }
167167

@@ -175,7 +175,7 @@ internal struct InternalSubscripts {
175175
}
176176
}
177177

178-
internal struct InternalStatics {
178+
internal struct StructInternalStatics {
179179
internal static func internalStaticFunc() {}
180180
private static func privateStaticFunc() {}
181181

@@ -198,7 +198,7 @@ internal struct InternalStatics {
198198
}
199199
}
200200

201-
internal struct InternalGeneric<T, U, V> {
201+
internal struct StructInternalGeneric<T, U, V> {
202202
internal var internalVar: U
203203
private var privateVar: V
204204

@@ -218,19 +218,19 @@ internal struct InternalGeneric<T, U, V> {
218218
}
219219

220220

221-
private struct PrivateNothing {}
221+
private struct StructPrivateNothing {}
222222

223-
private struct PrivateInit {
223+
private struct StructPrivateInit {
224224
private init() {}
225225
private init(private_: Int) {}
226226
}
227227

228-
private struct PrivateMethods {
228+
private struct StructPrivateMethods {
229229
private init() {}
230230
private func privateMethod() {}
231231
}
232232

233-
private struct PrivateProperties {
233+
private struct StructPrivateProperties {
234234
private let privateLet: Int = 0
235235

236236
private var privateVar: Int = 0
@@ -243,7 +243,7 @@ private struct PrivateProperties {
243243
}
244244
}
245245

246-
private struct PrivateSubscripts {
246+
private struct StructPrivateSubscripts {
247247
private subscript(privateGet _: Int) -> Int { return 0 }
248248

249249
private subscript(privateGetSet _: Int) -> Int {
@@ -252,7 +252,7 @@ private struct PrivateSubscripts {
252252
}
253253
}
254254

255-
private struct PrivateStatics {
255+
private struct StructPrivateStatics {
256256
private static func privateStaticFunc() {}
257257

258258
private static let privateLet: Int = 0
@@ -267,7 +267,7 @@ private struct PrivateStatics {
267267
}
268268
}
269269

270-
private struct PrivateGeneric<T, U, V> {
270+
private struct StructPrivateGeneric<T, U, V> {
271271
private var privateVar: V
272272

273273
private var privateVarConcrete: Int = 0

0 commit comments

Comments
 (0)