Skip to content

Commit 92cb05b

Browse files
committed
Add test for building a module with -use-interface-for-module that imports a module with package name
Ref: rdar://108945440
1 parent 3f5cb3d commit 92cb05b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// REQUIRES: VENDOR=apple
2+
3+
// RUN: %empty-directory(%t.mod)
4+
// RUN: %empty-directory(%t.sdk)
5+
// RUN: %empty-directory(%t.module-cache)
6+
// RUN: split-file %s %t
7+
8+
// Make sure api-digester loads an interface with package-name correctly
9+
10+
// Generate module Lib
11+
// RUN: %target-swift-frontend %t/Lib.swift -emit-module -module-name Lib -emit-module-path %t.mod/Lib.swiftmodule -emit-module-interface-path %t.mod/Lib.swiftinterface -emit-private-module-interface-path %t.mod/Lib.private.swiftinterface -package-name myLib -parse-as-library -enable-library-evolution -module-cache-path %t.module-cache -swift-version 5
12+
13+
// Dumping sdk for Lib ABI via .swiftmodule file should work
14+
// RUN: %api-digester -dump-sdk -abort-on-module-fail -abi -module Lib -o - -module-cache-path %t.module-cache -I %t.mod > %t.dump-lib-interface.json
15+
16+
// Dumping sdk file for Lib ABI via .swiftinterface file should work
17+
// RUN: %api-digester -dump-sdk -abort-on-module-fail -abi -module Lib -use-interface-for-module Lib -o - -module-cache-path %t.module-cache -I %t.mod > %t.dump-lib-interface.json
18+
19+
// Generate module Client
20+
// RUN: %target-swift-frontend %t/Client.swift -emit-module -module-name Client -emit-module-path %t.mod/Client.swiftmodule -emit-module-interface-path %t.mod/Client.swiftinterface -emit-private-module-interface-path %t.mod/Client.private.swiftinterface -package-name myLib -parse-as-library -enable-library-evolution -module-cache-path %t.module-cache -swift-version 5 -I %t.mod
21+
22+
// RUN: rm -f %t.mod/Lib.swiftmodule
23+
// RUN: rm -f %t.module-cache/Lib*.swiftmodule
24+
25+
// Dumping sdk for Client ABI via .swiftmodule file should work
26+
// RUN: %api-digester -dump-sdk -abort-on-module-fail -abi -module Client -o - -module-cache-path %t.module-cache -I %t.mod > %t.dump-client-interface.json
27+
28+
// Dumping sdk for Client ABI via .swiftinterface file should work
29+
// RUN: %api-digester -dump-sdk -abort-on-module-fail -abi -module Client -use-interface-for-module Client -o - -module-cache-path %t.module-cache -I %t.mod > %t.dump-client-interface.json
30+
31+
32+
//--- Lib.swift
33+
package class P {
34+
package class func foo() {}
35+
package func foo2(_ : Int) {}
36+
package weak var bar : P?
37+
package var bar2 : P?
38+
}
39+
40+
package func lambdafunc() -> (P) -> () { return { _ in } }
41+
42+
public struct S {
43+
package init(_ : P?) {}
44+
public static func baz(_ arg: String?) {}
45+
}
46+
47+
//--- Client.swift
48+
import Lib
49+
50+
func clientFunc() {
51+
let s = S(nil)
52+
S.baz("")
53+
P.foo()
54+
let result = lambdafunc()
55+
print(s, result)
56+
}

0 commit comments

Comments
 (0)