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
|
// This test checks that the value of the symbols.swift-module-loading-mode
// setting is respected when loading Swift modules.
// Note: It intentionally does not check the only-interface or prefer-interface
// modes as this also causes the Swift stdlib to be loaded via its module
// interface file, which slows down this test considerably.
// REQUIRES: swift
// RUN: rm -rf %t && mkdir %t
// Setup generates a dylib and .swiftinterface for A.swift as is, but generates
// the .swiftmodule from a modified version a A.swift where the 'FromInterface'
// type has been renamed to 'FromSerialized'. This means that the 'testValue'
// variable will have a different type depending on whether the module was
// loaded via the .swiftinterface or .swiftmodule.
// RUN: mkdir %t/mcp
// RUN: mkdir %t/lib
// RUN: cp %S/Inputs/A.swift %t/AA.swift
// RUN: %target-swiftc -module-name AA -emit-module-interface-path %t/lib/AA.swiftinterface -emit-library -o %t/lib/libAA%target-shared-library-suffix %t/AA.swift
// RUN: sed -e 's/FromInterface/FromSerialized/g' %t/AA.swift | %target-swiftc -module-name AA -emit-module -o %t/lib/AA.swiftmodule -
// RUN: rm %t/AA.swift
// This is the input provided to lldb. It intentionally assigns 'testValue' to
// a variable of the incorrect type so we can tell via the produced diagnostic
// whether the .swiftinterface or .swiftmodule was used.
import AA
let x: OtherType = testValue
// NOT-LOADED: cannot find type 'OtherType' in scope
// FROM-INTERFACE: cannot convert value of type 'FromInterface' to specified type 'OtherType'
// FROM-SERIALIZED: cannot convert value of type 'FromSerialized' to specified type 'OtherType'
// INVALID: error: invalid enumeration value '{{.*}}', valid values are: {{.*}}
// 1. Neither .swiftinterface or .swiftmodule present
//
// RUN: mv %t/lib %t/lib-backup
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode prefer-serialized" < %s 2>&1 | FileCheck %s -check-prefix=NOT-LOADED
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode only-serialized" < %s 2>&1 | FileCheck %s -check-prefix=NOT-LOADED
// 2. .swiftinterface only
//
// RUN: mkdir %t/lib
// RUN: cp %t/lib-backup/AA.swiftinterface %t/lib/
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode prefer-serialized" < %s 2>&1 | FileCheck %s -check-prefix=FROM-INTERFACE
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode only-serialized" < %s 2>&1 | FileCheck %s -check-prefix=NOT-LOADED
// 3. .swiftinterface and .swiftmodule
//
// RUN: cp %t/lib-backup/AA.swiftmodule %t/lib/
// RUN: rm -rf %t/mcp/AA*
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode prefer-serialized" < %s 2>&1 | FileCheck %s -check-prefix=FROM-SERIALIZED
// RUN: rm -rf %t/mcp/AA*
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode only-serialized" < %s 2>&1 | FileCheck %s -check-prefix=FROM-SERIALIZED
// RUN: rm -rf %t/mcp/AA*
// 4. .swiftmodule only
// RUN: rm %t/lib/AA.swiftinterface
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode prefer-serialized" < %s 2>&1 | FileCheck %s -check-prefix=FROM-SERIALIZED
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode only-serialized" < %s 2>&1 | FileCheck %s -check-prefix=FROM-SERIALIZED
// 5. Check invalid values are rejected
// RUN: %lldb --repl="-I%t/lib -L%t/lib -lAA" -O "settings set symbols.clang-modules-cache-path %t/mcp" \
// RUN: -O "settings set symbols.swift-module-loading-mode garbage" < %s 2>&1 | FileCheck %s -check-prefix=INVALID
|