|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %empty-directory(%t/clang-module-cache) |
| 3 | +// RUN: %empty-directory(%t/Modules) |
| 4 | +// RUN: %empty-directory(%t/PackageModules) |
| 5 | +// RUN: %empty-directory(%t/PackageModules/Foo.swiftmodule) |
| 6 | +// RUN: %empty-directory(%t/Modules/Bar.swiftmodule) |
| 7 | +// RUN: %empty-directory(%t/TextualInterfaces) |
| 8 | +// RUN: %empty-directory(%t/TextualInterfaces/Bar.swiftmodule) |
| 9 | +// RUN: split-file %s %t |
| 10 | + |
| 11 | +// Step 1: Build Foo Swift binary module |
| 12 | +// RUN: %target-swift-frontend -emit-module %t/Foo.swift -emit-module-path %t/PackageModules/Foo.swiftmodule/%target-swiftmodule-name -module-name Foo |
| 13 | + |
| 14 | +// Step 2: Build Bar Swift binary module and textual interface with a package-only import |
| 15 | +// RUN: %target-swift-frontend -emit-module %t/Bar.swift -emit-module-path %t/Modules/Bar.swiftmodule/%target-swiftmodule-name -module-name Bar -enable-library-evolution -emit-module-interface-path %t/TextualInterfaces/Bar.swiftmodule/%target-swiftinterface-name -emit-private-module-interface-path %t/TextualInterfaces/Bar.swiftmodule/%target-private-swiftinterface-name -emit-package-module-interface-path %t/TextualInterfaces/Bar.swiftmodule/%target-package-swiftinterface-name -I %t/PackageModules/ -package-name BarTest |
| 16 | + |
| 17 | +// Step 3: Now that Bar has been built, remove package-only dependency 'Foo' so that any clients of 'Bar' fail to build if they search for it |
| 18 | +// RUN: rm -rf %t/PackageModules/* |
| 19 | + |
| 20 | + |
| 21 | +// Test 1: Build a textual interface client which imports Bar and is in Bar's package but not being built from a package interface, therefore it must not import Bar's package-only dependencies |
| 22 | +// RUN: %target-swift-frontend -compile-module-from-interface -explicit-interface-module-build %t/Client.swiftinterface -o %t/Modules/Client.swiftmodule -module-name Client -I %t/Modules/ -package-name BarTest |
| 23 | + |
| 24 | +// Test 2: Build a textual interface client which imports Bar and is in Bar's package and is being built from a package interface, therefore it must import Bar's package-only dependencies |
| 25 | +// RUN: not %target-swift-frontend -compile-module-from-interface -explicit-interface-module-build %t/Client.package.swiftinterface -o %t/Modules/Client.package.swiftmodule -module-name Client -I %t/Modules/ -package-name BarTest &> %t/error.txt |
| 26 | +// RUN %FileCheck --check-prefix=CHECK-MISSING-FOO %s < %t/error.txt |
| 27 | + |
| 28 | +// Test 3: Build a source client which imports Bar but is not in Bar's package, therefore it must not import Bar's package-only dependencies |
| 29 | +// RUN: %target-swift-frontend -emit-module %t/Client.swift -emit-module-path %t/Modules/SourceClient.swiftmodule/%target-swiftmodule-name -module-name Client -I %t/Modules/ |
| 30 | + |
| 31 | +// Test 4: Build a source client which imports Bar but and is in Bar's package, therefore it must import Bar's package-only dependencies |
| 32 | +// RUN: not %target-swift-frontend -emit-module %t/Client.swift -emit-module-path %t/Modules/SourceClient.swiftmodule/%target-swiftmodule-name -module-name Client -I %t/Modules/ -package-name BarTest &> %t/source_error.txt |
| 33 | +// RUN %FileCheck --check-prefix=CHECK-MISSING-FOO %s < %t/source_error.txt |
| 34 | + |
| 35 | +// CHECK-MISSING-FOO: error: missing required module 'Foo' |
| 36 | + |
| 37 | +//--- Foo.swift |
| 38 | +public func foo() {} |
| 39 | + |
| 40 | +//--- Bar.swift |
| 41 | +package import Foo |
| 42 | + |
| 43 | +//--- Client.swiftinterface |
| 44 | +// swift-interface-format-version: 1.0 |
| 45 | +// swift-module-flags: -swift-version 5 -enable-library-evolution -module-name Client |
| 46 | +import Bar |
| 47 | +public func test() {} |
| 48 | + |
| 49 | +//--- Client.package.swiftinterface |
| 50 | +// swift-interface-format-version: 1.0 |
| 51 | +// swift-module-flags: -swift-version 5 -enable-library-evolution -module-name Client -package-name BarTest |
| 52 | +import Bar |
| 53 | +public func test() {} |
| 54 | + |
| 55 | +//--- Client.swift |
| 56 | +import Bar |
| 57 | + |
| 58 | + |
| 59 | + |
0 commit comments