|
| 1 | +/// Tests the fallback behavior for runtime library import paths on macCatalyst. These |
| 2 | +/// should prefer the resource directory, then the SDK's System/iOSSupport |
| 3 | +/// directory, then the SDK's root. Contrariwise, test that iOSSupport is *not* |
| 4 | +/// used on any other platform. |
| 5 | + |
| 6 | +// Test format: We try to type-check this file with different combinations of |
| 7 | +// mock resource directories and SDKs. If it loads a standard library, |
| 8 | +// typechecking will fail with a message that includes the word "success" (from |
| 9 | +// the name of the undefined function we try to call). If it tries to load a |
| 10 | +// standard library it shouldn't reach, loading will fail with a message that |
| 11 | +// includes the word "failure" (from the target triples we insert into the |
| 12 | +// bad .swiftmodule directories). If it can't even find a standard library to |
| 13 | +// attempt to load, the error message will contain neither "success" nor |
| 14 | +// "failure"; this should happen only in the last test case. |
| 15 | + |
| 16 | +// REQUIRES: maccatalyst_support |
| 17 | + |
| 18 | +// This symbol does not exist in the standard library. |
| 19 | +Swift.success() |
| 20 | + |
| 21 | +// ***** SDKs AND RESOURCE DIRECTORIES ***** |
| 22 | + |
| 23 | +// bad-bad-sdk has bad stdlibs in both iOSSupport and the root. |
| 24 | +// |
| 25 | +// RUN: %empty-directory(%t/bad-bad-sdk) |
| 26 | +// RUN: mkdir -p %t/bad-bad-sdk/System/iOSSupport/usr/lib/swift/Swift.swiftmodule |
| 27 | +// RUN: touch %t/bad-bad-sdk/System/iOSSupport/usr/lib/swift/Swift.swiftmodule/failure-failure-failure.swiftmodule |
| 28 | +// RUN: mkdir -p %t/bad-bad-sdk/usr/lib/swift/Swift.swiftmodule |
| 29 | +// RUN: touch %t/bad-bad-sdk/usr/lib/swift/Swift.swiftmodule/failure-failure-failure.swiftmodule |
| 30 | + |
| 31 | +// good-bad-sdk has a good stdlib in iOSSupport and a bad stdlib in the root. |
| 32 | +// |
| 33 | +// RUN: %empty-directory(%t/good-bad-sdk) |
| 34 | +// RUN: mkdir -p %t/good-bad-sdk/System/iOSSupport/usr/lib/swift |
| 35 | +// RUN: cp -r %test-resource-dir/maccatalyst/Swift.swiftmodule %t/good-bad-sdk/System/iOSSupport/usr/lib/swift/Swift.swiftmodule |
| 36 | +// RUN: mkdir -p %t/good-bad-sdk/usr/lib/swift/Swift.swiftmodule |
| 37 | +// RUN: touch %t/good-bad-sdk/usr/lib/swift/Swift.swiftmodule/failure-failure-failure.swiftmodule |
| 38 | + |
| 39 | +// bad-good-sdk has a bad stdlib in iOSSupport and a good stdlib in the root. |
| 40 | +// Note that for the stdlib in this case to be "good", it needs to be universal. |
| 41 | +// |
| 42 | +// RUN: %empty-directory(%t/bad-good-sdk) |
| 43 | +// RUN: mkdir -p %t/bad-good-sdk/System/iOSSupport/usr/lib/swift/Swift.swiftmodule |
| 44 | +// RUN: touch %t/bad-good-sdk/System/iOSSupport/usr/lib/swift/Swift.swiftmodule/failure-failure-failure.swiftmodule |
| 45 | +// RUN: mkdir -p %t/bad-good-sdk/usr/lib/swift |
| 46 | +// RUN: cp -r %test-resource-dir/maccatalyst/Swift.swiftmodule %t/bad-good-sdk/usr/lib/swift/Swift.swiftmodule |
| 47 | +// RUN: cp -r %test-resource-dir/macosx/Swift.swiftmodule/* %t/bad-good-sdk/usr/lib/swift/Swift.swiftmodule |
| 48 | + |
| 49 | +// empty-good-sdk has no stdlib in iOSSupport and a good stdlib in the root. |
| 50 | +// Note that for the stdlib in this case to be "good", it needs to be universal. |
| 51 | +// |
| 52 | +// RUN: %empty-directory(%t/empty-good-sdk) |
| 53 | +// RUN: mkdir -p %t/empty-good-sdk/System/iOSSupport/usr/lib/swift |
| 54 | +// RUN: mkdir -p %t/empty-good-sdk/usr/lib/swift |
| 55 | +// RUN: cp -r %test-resource-dir/maccatalyst/Swift.swiftmodule %t/empty-good-sdk/usr/lib/swift/Swift.swiftmodule |
| 56 | +// RUN: cp -r %test-resource-dir/macosx/Swift.swiftmodule/* %t/empty-good-sdk/usr/lib/swift/Swift.swiftmodule |
| 57 | + |
| 58 | +// empty-empty-sdk has no stdlib in iOSSupport or the root. |
| 59 | +// |
| 60 | +// RUN: %empty-directory(%t/empty-empty-sdk) |
| 61 | +// RUN: mkdir -p %t/empty-empty-sdk/System/iOSSupport/usr/lib/swift |
| 62 | +// RUN: mkdir -p %t/empty-empty-sdk/usr/lib/swift |
| 63 | + |
| 64 | +// We don't create a good-resourcedir; we just use the default one. |
| 65 | + |
| 66 | +// empty-resdir has no stdlib in it. |
| 67 | +// |
| 68 | +// RUN: %empty-directory(%t/empty-resdir/usr/lib/swift) |
| 69 | +// FIXME: Until we have private imports, we need SwiftShims in the toolchain. |
| 70 | +// RUN: cp -r %test-resource-dir/shims %t/empty-resdir/usr/lib/swift/shims |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +// ***** MACCATALYST TESTS ***** |
| 75 | + |
| 76 | +// RESDIR: If resource-dir has a standard library, it will be preferred |
| 77 | +// over sdk/iOSSupport. (default resource dir + bad-bad-sdk) |
| 78 | +// |
| 79 | +// RUN: %empty-directory(%t.mcp) |
| 80 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-bad-sdk) -target x86_64-apple-ios13.1-macabi -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=RESDIR-MACCATALYST |
| 81 | +// RESDIR-MACCATALYST: success |
| 82 | + |
| 83 | +// IOSSUP: If resource-dir has no standard library but sdk/iOSSupport does, it |
| 84 | +// will be preferred over sdk. (empty-resdir + good-bad-sdk) |
| 85 | +// |
| 86 | +// RUN: %empty-directory(%t.mcp) |
| 87 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/good-bad-sdk) -target x86_64-apple-ios13.1-macabi -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=IOSSUP-MACCATALYST |
| 88 | +// IOSSUP-MACCATALYST: success |
| 89 | + |
| 90 | +// IOSBAD: Confirms that we don't use sdk/iOSSupport on non-macCatalyst, even if |
| 91 | +// present. (empty-resdir + bad-good-sdk) |
| 92 | +// |
| 93 | +// RUN: %empty-directory(%t.mcp) |
| 94 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-good-sdk) -target x86_64-apple-ios13.1-macabi -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=IOSBAD-MACCATALYST |
| 95 | +// IOSBAD-MACCATALYST: failure |
| 96 | + |
| 97 | +// SDKTOP: If resource-dir and sdk/iOSSupport don't have standard libraries but |
| 98 | +// sdk does, it will be used as a last resort. (empty-resdir + empty-good-sdk) |
| 99 | +// |
| 100 | +// RUN: %empty-directory(%t.mcp) |
| 101 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/empty-good-sdk) -target x86_64-apple-ios13.1-macabi -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=SDKTOP-MACCATALYST |
| 102 | +// SDKTOP-MACCATALYST: success |
| 103 | + |
| 104 | +// NILLIB: If no standard libraries are available, stdlib loading fails. |
| 105 | +// (empty-resdir + empty-empty-sdk) This one has a different error message from |
| 106 | +// the others because there are no failure-failure-failure triples to find. |
| 107 | +// |
| 108 | +// RUN: %empty-directory(%t.mcp) |
| 109 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/empty-empty-sdk) -target x86_64-apple-ios13.1-macabi -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=NILLIB-MACCATALYST |
| 110 | +// NILLIB-MACCATALYST: unable to load standard library |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +// ***** MACOSX TESTS ***** |
| 115 | + |
| 116 | +// FIXME: Right now we're only building the ios-macabi swiftmodule when we |
| 117 | +// build for macCatalyst, so we need to accept "module 'Swfit' was created for |
| 118 | +// incompatible target" as successful. |
| 119 | + |
| 120 | +// RESDIR: If resource-dir has a standard library, it will be preferred |
| 121 | +// over sdk/iOSSupport. (default resource dir + bad-bad-sdk) |
| 122 | +// |
| 123 | +// RUN: %empty-directory(%t.mcp) |
| 124 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-bad-sdk) -target x86_64-apple-macosx10.15 -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=RESDIR-MACOSX |
| 125 | +// RESDIR-MACOSX: {{success|module 'Swift' was created for incompatible target}} |
| 126 | + |
| 127 | +// IOSSUP: If resource-dir has no standard library but sdk/iOSSupport does, it |
| 128 | +// will be preferred over sdk. (empty-resdir + good-bad-sdk) |
| 129 | +// |
| 130 | +// RUN: %empty-directory(%t.mcp) |
| 131 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/good-bad-sdk) -target x86_64-apple-macosx10.15 -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=IOSSUP-MACOSX |
| 132 | +// IOSSUP-MACOSX: failure |
| 133 | + |
| 134 | +// IOSBAD: Confirms that we don't use sdk/iOSSupport on non-macCatalyst, even if |
| 135 | +// present. (empty-resdir + bad-good-sdk) |
| 136 | +// |
| 137 | +// RUN: %empty-directory(%t.mcp) |
| 138 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/bad-good-sdk) -target x86_64-apple-macosx10.15 -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=IOSBAD-MACOSX |
| 139 | +// IOSBAD-MACOSX: {{success|module 'Swift' was created for incompatible target}} |
| 140 | + |
| 141 | +// SDKTOP: If resource-dir and sdk/iOSSupport don't have standard libraries but |
| 142 | +// sdk does, it will be used as a last resort. (empty-resdir + empty-good-sdk) |
| 143 | +// |
| 144 | +// RUN: %empty-directory(%t.mcp) |
| 145 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/empty-good-sdk) -target x86_64-apple-macosx10.15 -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=SDKTOP-MACOSX |
| 146 | +// SDKTOP-MACOSX: {{success|module 'Swift' was created for incompatible target}} |
| 147 | + |
| 148 | +// NILLIB: If no standard libraries are available, stdlib loading fails. |
| 149 | +// (empty-resdir + empty-empty-sdk) This one has a different error message from |
| 150 | +// the others because there are no failure-failure-failure triples to find. |
| 151 | +// |
| 152 | +// RUN: %empty-directory(%t.mcp) |
| 153 | +// RUN: not %target-swift-frontend(mock-sdk: -sdk %t/empty-empty-sdk) -target x86_64-apple-macosx10.15 -resource-dir %t/empty-resdir/usr/lib/swift -module-cache-path %t.mcp -typecheck %s 2>&1 | %FileCheck %s --check-prefix=NILLIB-MACOSX |
| 154 | +// NILLIB-MACOSX: unable to load standard library |
0 commit comments