|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %empty-directory(%t/MCP) |
| 3 | +// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule) |
| 4 | +// RUN: %empty-directory(%t/include/Lib.swiftmodule) |
| 5 | +// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/%target-cpu.swiftinterface |
| 6 | + |
| 7 | +// Prebuild a module for the current target CPU, and put it in the prebuilt cache under some imaginary CPU. |
| 8 | +// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %t/include/Lib.swiftmodule/%target-cpu.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/leg128.swiftmodule - -module-name Lib |
| 9 | + |
| 10 | +// Make sure that, if there's a module for a different architecture |
| 11 | +// present in the prebuilt cache, it's ignored and the module is |
| 12 | +// rebuilt from an interface. |
| 13 | + |
| 14 | +// RUN: not %target-swift-frontend -typecheck -module-cache-path %t/MCP -sdk %t/include -I %t/include -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck %s --check-prefix FROM-INTERFACE |
| 15 | +// RUN: %empty-directory(%t/MCP) |
| 16 | + |
| 17 | +// Make sure it works fine if the module is for this architecture. |
| 18 | +// RUN: mv %t/prebuilt-cache/Lib.swiftmodule/leg128.swiftmodule %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name |
| 19 | +// RUN: not %target-swift-frontend -typecheck -module-cache-path %t/MCP -sdk %t/include -I %t/include -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck %s --check-prefix FROM-PREBUILT |
| 20 | + |
| 21 | +// Now make sure it works if there's nothing in the prebuilt cache |
| 22 | +// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule) |
| 23 | +// RUN: %empty-directory(%t/MCP) |
| 24 | + |
| 25 | +// RUN: not %target-swift-frontend -typecheck -module-cache-path %t/MCP -sdk %t/include -I %t/include -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck %s --check-prefix FROM-INTERFACE |
| 26 | + |
| 27 | +import Lib |
| 28 | + |
| 29 | +struct X {} |
| 30 | +let _: X = Lib.testValue |
| 31 | +// FROM-PREBUILT: [[@LINE-1]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X' |
| 32 | +// FROM-INTERFACE: [[@LINE-2]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X' |
0 commit comments