Skip to content

Commit 03c8461

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

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
// The goal of this test to make sure flag -use-interface-for-module works.
9+
10+
// We first build .swiftinterface with -enable-library-evolution
11+
12+
// Secondly, we We first build .swiftmodule without -enable-library-evolution
13+
// Using swift-api-digester to load via .swiftinterface and .swiftmodule should
14+
// always give us some difference.
15+
16+
// Generate .swiftinterface file for module Lib
17+
18+
// RUN: %target-swift-frontend -emit-module -module-name Lib -emit-module-interface-path %t.mod/Lib.swiftinterface -emit-private-module-interface-path %t.mod/Lib.private.swiftinterface %t/Lib.swift -package-name myLib -parse-as-library -enable-library-evolution -module-cache-path %t.module-cache -swift-version 5
19+
20+
// Generate .swiftmodule file for module Lib
21+
// RUN: %target-swift-frontend -emit-module -o %t.mod/Lib.swiftmodule %t/Lib.swift -package-name myLib -parse-as-library -module-cache-path %t.module-cache -swift-version 5
22+
23+
// Dump Json file for Lib ABI via .swiftmodule file
24+
// 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-binary.json
25+
26+
// Dump Json file for Lib ABI via .swiftinterface file
27+
// 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
28+
29+
30+
// Typecheck client that imports Lib
31+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -package-name myLib -I %t.mod -I %t.module-cache -verify
32+
33+
// Generate .swiftinterface file for module Client
34+
// RUN: %target-swift-frontend -emit-module -module-name Client -emit-module-interface-path %t.mod/Client.swiftinterface -emit-private-module-interface-path %t.mod/Client.private.swiftinterface %t/Client.swift -package-name myLib -parse-as-library -enable-library-evolution -module-cache-path %t.module-cache -swift-version 5 -I %t.mod
35+
36+
// Generate .swiftmodule file for module Client
37+
// RUN: %target-swift-frontend -emit-module -o %t.mod/Client.swiftmodule %t/Client.swift -package-name myLib -parse-as-library -module-cache-path %t.module-cache -swift-version 5 -I %t.mod
38+
39+
// Dump Json file for Client ABI via .swiftmodule file
40+
// 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-binary.json
41+
42+
// Dump Json file for Client ABI via .swiftinterface file
43+
// 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
44+
45+
46+
//--- Lib.swift
47+
package class P {
48+
package class func foo() {}
49+
package func foo2(_ : Int) {}
50+
package weak var bar : P?
51+
package var bar2 : P?
52+
}
53+
54+
package func lambdafunc() -> (P) -> () { return { _ in } }
55+
56+
public struct S {
57+
package init(_ : P?) {}
58+
public static func baz(_ arg: String?) {}
59+
}
60+
61+
//--- Client.swift
62+
import Lib
63+
64+
func clientFunc() {
65+
let s = S(nil)
66+
S.baz("")
67+
P.foo()
68+
let result = lambdafunc()
69+
print(s, result)
70+
}

0 commit comments

Comments
 (0)