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