mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[test] Update ParseableInterface to ModuleInterface
Also remove uses of -emit-parseable-module-interface from tests
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
for input_path in sys.argv[1:]:
|
||||
with open(input_path, 'r') as yaml_file:
|
||||
# Forwarding files are YAML files that start with '---'
|
||||
if yaml_file.read(3) != '---':
|
||||
print("swiftmodule '%s' is not a forwarding module!" % input_path)
|
||||
sys.exit(1)
|
||||
27
test/ModuleInterface/ModuleCache/Inputs/check-is-new.py
Executable file
27
test/ModuleInterface/ModuleCache/Inputs/check-is-new.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# check-is-new.py - a more-legible way to read a timestamp test than test(1)
|
||||
#
|
||||
# This source file is part of the Swift.org open source project
|
||||
#
|
||||
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
|
||||
# Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
#
|
||||
# See https://swift.org/LICENSE.txt for license information
|
||||
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Compares the mtime of the provided files to a constant "old" reference time.
|
||||
# Fails if any file is as-old-or-older than old.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
OLD = 1390550700 # 2014-01-24T08:05:00+00:00
|
||||
for f in sys.argv[1:]:
|
||||
if os.stat(f).st_mtime <= OLD:
|
||||
print("%s is not new!" % f)
|
||||
exit(1)
|
||||
27
test/ModuleInterface/ModuleCache/Inputs/check-is-old.py
Executable file
27
test/ModuleInterface/ModuleCache/Inputs/check-is-old.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# check-is-old.py - a more-legible way to read a timestamp test than test(1)
|
||||
#
|
||||
# This source file is part of the Swift.org open source project
|
||||
#
|
||||
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
|
||||
# Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
#
|
||||
# See https://swift.org/LICENSE.txt for license information
|
||||
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Compares the mtime of the provided files to a constant "old" reference time.
|
||||
# Fails if any file has mtime not-equal to old.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
OLD = 1390550700 # 2014-01-24T08:05:00+00:00
|
||||
for f in sys.argv[1:]:
|
||||
if os.stat(f).st_mtime != OLD:
|
||||
print("%s is not old!" % f)
|
||||
exit(1)
|
||||
@@ -0,0 +1,9 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name Lib
|
||||
|
||||
public struct FromInterface {
|
||||
@inlinable public init() {}
|
||||
}
|
||||
public var testValue: FromInterface {
|
||||
@inlinable get { return FromInterface() }
|
||||
}
|
||||
24
test/ModuleInterface/ModuleCache/Inputs/make-old.py
Executable file
24
test/ModuleInterface/ModuleCache/Inputs/make-old.py
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# make-old.py - /bin/touch that writes a constant "old" timestamp.
|
||||
#
|
||||
# This source file is part of the Swift.org open source project
|
||||
#
|
||||
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
|
||||
# Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
#
|
||||
# See https://swift.org/LICENSE.txt for license information
|
||||
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Like /bin/touch, but writes a constant "old" timestamp.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
OLD = 1390550700 # 2014-01-24T08:05:00+00:00
|
||||
for f in sys.argv[1:]:
|
||||
os.utime(f, (OLD, OLD))
|
||||
@@ -0,0 +1,11 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name ExportedLib
|
||||
|
||||
@_exported import SomeCModule
|
||||
|
||||
public struct ExportedInterface {
|
||||
@inlinable public init() {}
|
||||
}
|
||||
public var testValue: ExportedInterface {
|
||||
@inlinable get { return ExportedInterface() }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name SdkLib
|
||||
|
||||
@_exported import ExportedLib
|
||||
|
||||
public var testValue2: ExportedInterface {
|
||||
@inlinable get { return ExportedInterface() }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
extern int x;
|
||||
@@ -0,0 +1,3 @@
|
||||
module SomeCModule {
|
||||
header "SomeCModule.h"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name Lib
|
||||
|
||||
public struct FromInterface {
|
||||
@inlinable public init() {}
|
||||
}
|
||||
public var testValue: FromInterface {
|
||||
@inlinable get { return FromInterface() }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -parse-stdlib -module-name LibExporter
|
||||
|
||||
@_exported import Lib
|
||||
@@ -0,0 +1,10 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name ObjCAttrWithoutFoundation -enable-library-evolution -enable-objc-interop
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'import ObjCAttrWithoutFoundation' | %target-swift-frontend -typecheck -module-cache-path %t -I %S -
|
||||
|
||||
public class MyClass {
|
||||
public init()
|
||||
@objc deinit
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
// RUN: %empty-directory(%t/PrebuiltCache)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Create an empty .swiftmodule, which will force recompiling from the interface
|
||||
// RUN: touch %t/Build/TestModule.swiftmodule
|
||||
|
||||
// 4. Try to import the malformed compiled module
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{is out of date}}
|
||||
// expected-note @-2 {{malformed}}
|
||||
@@ -0,0 +1,31 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create both an interface and a compiled module for it
|
||||
// RUN: %target-swift-frontend -emit-module -o %t/Build/TestModule.swiftmodule %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5 -module-name TestModule
|
||||
|
||||
// 3. Make the compiled module unreadable so it gets added as a dependency but is not used
|
||||
// RUN: mv %t/Build/TestModule.swiftmodule %t/Build/TestModule.swiftmodule.moved-aside
|
||||
// RUN: echo 'this is unreadable' > %t/Build/TestModule.swiftmodule
|
||||
|
||||
// 4. Try to import the module, which will create a cached module that depends on both the .swiftmodule and .swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -module-cache-path %t/ModuleCache
|
||||
|
||||
// 5. Remove the .swiftmodule, which will result in a missing dependency note
|
||||
// RUN: rm %t/Build/TestModule.swiftmodule
|
||||
|
||||
// 6. Rebuild with remarks enabled, make sure the missing dependency note is emitted
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
// 7. Put the module back, make the interface unreadable, and make sure the compiler succeeds
|
||||
// RUN: mv %t/Build/TestModule.swiftmodule.moved-aside %t/Build/TestModule.swiftmodule
|
||||
// RUN: mv %t/Build/TestModule.swiftinterface %t/Build/TestModule.swiftinterface.moved-aside
|
||||
// RUN: echo 'this is unreadable' > %t/Build/TestModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{cached module is out of date}}
|
||||
// expected-note @-2 {{dependency is missing}}
|
||||
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Try to import the interface, which will pass and create a cached module
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -module-cache-path %t/ModuleCache
|
||||
|
||||
// 3a. Make sure the test works on a fast machine
|
||||
// RUN: sleep 1
|
||||
|
||||
// 4. Touch the interface so the cached module is no longer up-to-date
|
||||
// RUN: %{python} %S/../Inputs/make-old.py %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 5. Try to import the now out-of-date cached module
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{cached module is out of date}}
|
||||
// expected-note @-2 {{dependency is out of date}}
|
||||
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Build the .swiftinterface to a .swiftmodule, which will have a dependency on the interface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/Build/TestModule.swiftmodule %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 3a. Make sure the test works on a fast machine
|
||||
// RUN: sleep 1
|
||||
|
||||
// 4. Touch the interface so the module is no longer up-to-date
|
||||
// RUN: %{python} %S/../Inputs/make-old.py %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 5. Try to import the out-of-date compiled module
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{compiled module is out of date}}
|
||||
// expected-note @-2 {{dependency is out of date}}
|
||||
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
// RUN: %empty-directory(%t/PrebuiltCache)
|
||||
|
||||
// 1. Create a dummy module
|
||||
// RUN: echo 'public func publicFunction() {}' > %t/TestModule.swift
|
||||
|
||||
// 2. Create an interface for it
|
||||
// RUN: %target-swift-frontend -typecheck %t/TestModule.swift -emit-module-interface-path %t/Build/TestModule.swiftinterface -swift-version 5
|
||||
|
||||
// 3. Build the .swiftinterface to a .swiftmodule in the prebuilt cache, which will have a dependency on the interface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Build/TestModule.swiftinterface -o %t/PrebuiltCache/TestModule.swiftmodule
|
||||
|
||||
// 5. Try to import the prebuilt module (this should pass)
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -sdk %t -prebuilt-module-cache-path %t/PrebuiltCache -module-cache-path %t/ModuleCache
|
||||
|
||||
// 6. Make sure we installed a forwarding module in the cache
|
||||
// RUN: %{python} %S/../Inputs/check-is-forwarding-module.py %t/ModuleCache/TestModule-*.swiftmodule
|
||||
|
||||
// 7. Modify the interface so the forwarding module and prebuilt modules are no longer up-to-date
|
||||
// RUN: echo ' ' >> %t/Build/TestModule.swiftinterface
|
||||
|
||||
// 8. Try to import the now out-of-date forwarding module, which will fail.
|
||||
// It will also fail to load the prebuilt module after the forwarding module
|
||||
// is rejected, meaning we'll get a second set of notes about the prebuilt module.
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s -I %t/Build -Rmodule-interface-rebuild -sdk %t -prebuilt-module-cache-path %t/PrebuiltCache -module-cache-path %t/ModuleCache
|
||||
|
||||
import TestModule // expected-remark {{rebuilding module 'TestModule' from interface}}
|
||||
// expected-note @-1 {{forwarding module is out of date}}
|
||||
// expected-note @-2 {{dependency is out of date}}
|
||||
// expected-note @-3 {{prebuilt module is out of date}}
|
||||
// expected-note @-4 {{dependency is out of date}}
|
||||
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/Build)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
|
||||
// 1. Create a module called InnerModule, and put its interface into the build dir.
|
||||
// RUN: echo 'public func inInnerModule() {}' | %target-swift-frontend - -typecheck -emit-module-interface-path %t/Build/InnerModule.swiftinterface -enable-library-evolution -swift-version 5 -module-name InnerModule
|
||||
|
||||
// 2. Build the .swiftinterface to a .swiftmodule, which will have a dependency on the interface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/Build/InnerModule.swiftmodule %t/Build/InnerModule.swiftinterface
|
||||
|
||||
// 3. Touch the interface so the module becomes out of date.
|
||||
// RUN: %{python} %S/../Inputs/make-old.py %t/Build/InnerModule.swiftinterface
|
||||
|
||||
// 4. Create a module called OuterModule that imports InnerModule, and put its interface into the build dir.
|
||||
// RUN: echo 'import InnerModule' | %target-swift-frontend - -emit-module -o %t/Build/OuterModule.swiftmodule -module-name OuterModule -I %t/Build
|
||||
|
||||
// 5. Build this file, and expect that InnerModule is out of date
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/Build -Rmodule-interface-rebuild -module-cache-path %t/ModuleCache 2>&1 | %FileCheck %s
|
||||
|
||||
import OuterModule
|
||||
|
||||
// CHECK: rebuilding module 'InnerModule' from interface '{{.*}}{{[/\\]}}Build{{[/\\]}}InnerModule.swiftinterface'
|
||||
// CHECK: compiled module is out of date: '{{.*}}{{[/\\]}}Build{{[/\\]}}InnerModule.swiftmodule'
|
||||
// CHECK: dependency is out of date: '{{.*}}{{[/\\]}}Build{{[/\\]}}InnerModule.swiftinterface'
|
||||
@@ -0,0 +1,192 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1) Build a prebuilt cache for our SDK
|
||||
//
|
||||
// RUN: mkdir %t/MCP %t/prebuilt-cache %t/my-sdk
|
||||
// RUN: cp -r %S/Inputs/mock-sdk/. %t/my-sdk
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
//
|
||||
// Check the prebuilt modules don't contain dependencies in the module cache, prebuilt cache, or resource dir
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// PREBUILT: MODULE_BLOCK
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]MCP[/\\]}}
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]prebuilt-cache[/\\]}}
|
||||
// PREBUILD-NOT: FILE_DEPENDENCY {{.*[/\\]lib[/\\]swift[/\\]}}
|
||||
//
|
||||
// Re-build them in the opposite order
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
//
|
||||
// Check they still don't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '1: PASSED'
|
||||
|
||||
|
||||
// 2) Baseline check: Make sure we use the interface when not passing the prebuilt module cache path
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check they are *not* forwarding modules
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they don't contain dependencies in the module cache (..or prebuilt cache)
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
//
|
||||
// DEPFILE-DAG: SomeCModule.h
|
||||
// DEPFILE-DAG: SdkLib.swiftinterface
|
||||
// DEPFILE-DAG: ExportedLib.swiftinterface
|
||||
// DEPFILE-DAG: SDKDependencies-disable-validation.swift
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '2: PASSED'
|
||||
|
||||
|
||||
// 3) Baseline check: Make sure we use the the prebuilt module cache when using the SDK it was built with
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they *are* forwarding modules
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they contain the expected dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefixes=EXLIB,SDKLIB
|
||||
//
|
||||
// EXLIB: dependencies:
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}module.modulemap'
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}SomeCModule.h'
|
||||
// EXLIB-DAG: path: ExportedLib.swiftinterface
|
||||
// SDKLIB-DAG: SdkLib.swiftinterface
|
||||
//
|
||||
// Check they don't contain any dependencies from either cache other than themselves
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
|
||||
//
|
||||
// NOCACHE: dependencies:
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// NOCACHE: {{[/\\]prebuilt-cache[/\\]}}[[LIB_NAME]].swiftmodule
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: echo '3: PASSED'
|
||||
|
||||
|
||||
// 4) Now change the SDK's content WITHOUT clearing the module cache and check
|
||||
// that it doesn't change anything...
|
||||
//
|
||||
// RUN: echo "// size change" >> %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check that they're both still forwarding modules, because we didn't stat
|
||||
// the system dependencies.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib still contains the same dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
//
|
||||
// RUN: echo '4: PASSED'
|
||||
|
||||
// 5) ...but if we clear the module cache and start over, we won't be using the
|
||||
// prebuilt module anymore for SDKLib.
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib still contains the same dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
//
|
||||
// Check SdkLib doesn't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: echo '5: PASSED'
|
||||
|
||||
// 6) If we do one more change, we won't rebuild SdkLib *again*...
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: echo "// size change" >> %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -disable-modules-validate-system-headers %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check SdkLib hasn't been rebuilt.
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// RUN: echo '6: PASSED'
|
||||
|
||||
// 7) ...until we turn off -disable-modules-validate-system-headers.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: echo "// size change" >> %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check SdkLib has been rebuilt.
|
||||
// RUN: not %{python} %S/Inputs/check-is-old.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// RUN: echo '7: PASSED'
|
||||
|
||||
|
||||
import SdkLib
|
||||
|
||||
func foo() -> ExportedInterface {
|
||||
return x > 3 ? testValue : testValue2
|
||||
}
|
||||
208
test/ModuleInterface/ModuleCache/SDKDependencies.swift
Normal file
208
test/ModuleInterface/ModuleCache/SDKDependencies.swift
Normal file
@@ -0,0 +1,208 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1) Build a prebuilt cache for our SDK
|
||||
//
|
||||
// RUN: mkdir %t/MCP %t/prebuilt-cache %t/my-sdk
|
||||
// RUN: cp -r %S/Inputs/mock-sdk/. %t/my-sdk
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
//
|
||||
// Check the prebuilt modules don't contain dependencies in the module cache, prebuilt cache, or resource dir
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// PREBUILT: MODULE_BLOCK
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]MCP[/\\]}}
|
||||
// PREBUILT-NOT: FILE_DEPENDENCY {{.*[/\\]prebuilt-cache[/\\]}}
|
||||
// PREBUILD-NOT: FILE_DEPENDENCY {{.*[/\\]lib[/\\]swift[/\\]}}
|
||||
//
|
||||
// Re-build them in the opposite order
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
|
||||
//
|
||||
// Check they still don't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '1: PASSED'
|
||||
|
||||
|
||||
// 2) Baseline check: Make sure we use the interface when not passing the prebuilt module cache path
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check they are *not* forwarding modules
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they don't contain dependencies in the module cache (..or prebuilt cache)
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// DEPFILE-NEGATIVE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
//
|
||||
// DEPFILE-DAG: SomeCModule.h
|
||||
// DEPFILE-DAG: SdkLib.swiftinterface
|
||||
// DEPFILE-DAG: ExportedLib.swiftinterface
|
||||
// DEPFILE-DAG: SDKDependencies.swift
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '2: PASSED'
|
||||
|
||||
|
||||
// 3) Baseline check: Make sure we use the the prebuilt module cache when using the SDK it was built with
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-sdk -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they *are* forwarding modules
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they contain the expected dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefixes=EXLIB,SDKLIB
|
||||
//
|
||||
// EXLIB: dependencies:
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}module.modulemap'
|
||||
// EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}SomeCModule.h'
|
||||
// EXLIB-DAG: path: ExportedLib.swiftinterface
|
||||
// SDKLIB-DAG: SdkLib.swiftinterface
|
||||
//
|
||||
// Check they don't contain any dependencies from either cache other than themselves
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
|
||||
//
|
||||
// NOCACHE: dependencies:
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
// NOCACHE: {{[/\\]prebuilt-cache[/\\]}}[[LIB_NAME]].swiftmodule
|
||||
// NOCACHE-NOT: {{[/\\]prebuilt-cache[/\\]}}
|
||||
// NOCACHE-NOT: {{[/\\]MCP[/\\]}}
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '3: PASSED'
|
||||
|
||||
|
||||
// 4) Move the SDK without changing its contents
|
||||
//
|
||||
// RUN: mv %t/my-sdk %t/my-new-sdk
|
||||
// RUN: mkdir %t/new-dir
|
||||
// RUN: mv %t/prebuilt-cache %t/new-dir/
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SdkLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they are still both forwarding modules
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check they contain the expected dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NEW-EXLIB
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefixes=NEW-EXLIB,NEW-SDKLIB
|
||||
//
|
||||
// NEW-EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}module.modulemap'
|
||||
// NEW-EXLIB-DAG: path: '{{usr[/\\]include[/\\]}}SomeCModule.h'
|
||||
// NEW-EXLIB-DAG: path: ExportedLib.swiftinterface
|
||||
// NEW-SDKLIB-DAG: path: SdkLib.swiftinterface
|
||||
//
|
||||
// Check they don't contain dependencies from the module cache, old prebuilt
|
||||
// cache, or new prebuilt cache
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: echo '4: PASSED'
|
||||
|
||||
|
||||
// 5) Now change the SDK's content and check it no longer uses the prebuilt modules
|
||||
//
|
||||
// RUN: echo "// size change" >> %t/my-new-sdk/SdkLib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SDKLib and ExportedLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib is still a forwarding module and SdkLib is not
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
//
|
||||
// Check ExportedLib still contains the same dependencies
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NEW-EXLIB
|
||||
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
|
||||
//
|
||||
// Check SdkLib doesn't contain dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
//
|
||||
// RUN: echo "// size change" >> %t/my-new-sdk/usr/include/SomeCModule.h
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
|
||||
//
|
||||
// Check SDKLib and ExportLib are in the module cache
|
||||
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check neither are forwarding modules
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
|
||||
//
|
||||
// Check neither contains dependencies in the module cache or prebuilt cache
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
|
||||
//
|
||||
// Check we didn't emit anything from the cache in the .d file either
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPFILE
|
||||
//
|
||||
// RUN: echo '5: PASSED'
|
||||
|
||||
|
||||
// 6) Keeping the existing cache, update ExportedLib to no longer depend on SomeCModule
|
||||
//
|
||||
// RUN: grep -v import %t/my-new-sdk/ExportedLib.swiftinterface > %t/my-new-sdk/ExportedLib.swiftinterface.updated
|
||||
// RUN: mv %t/my-new-sdk/ExportedLib.swiftinterface.updated %t/my-new-sdk/ExportedLib.swiftinterface
|
||||
//
|
||||
// RUN: sed -e 's/x > 3/5 > 3/g' %s | %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies -
|
||||
//
|
||||
// Check we don't have SomeCModule listed in dependencies
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefixes=DEPFILE-NEGATIVE,DEPCHANGE-NEGATIVE
|
||||
// RUN: cat %t/dummy.d | %FileCheck %s -check-prefix=DEPCHANGE
|
||||
//
|
||||
// DEPCHANGE-NEGATIVE-NOT: SomeCModule.h
|
||||
//
|
||||
// DEPCHANGE-DAG: SdkLib.swiftinterface
|
||||
// DEPCHANGE-DAG: ExportedLib.swiftinterface
|
||||
// DEPCHANGE-DAG: SDKDependencies.swift
|
||||
|
||||
import SdkLib
|
||||
|
||||
func foo() -> ExportedInterface {
|
||||
return x > 3 ? testValue : testValue2
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name SerializedSIL -enable-library-evolution
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'import SerializedSIL' | %target-swift-frontend -typecheck -module-cache-path %t -I %S -
|
||||
// RUN: %target-sil-opt -disable-sil-linking %t/SerializedSIL-*.swiftmodule -module-name SerializedSIL > %t/SerializedSIL.sil
|
||||
// RUN: %FileCheck %s < %t/SerializedSIL.sil
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/SerializedSIL.sil
|
||||
|
||||
public class TestClass {
|
||||
public init()
|
||||
public func method()
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
public var prop: Int { get set }
|
||||
public var storedProp: Int
|
||||
public static var staticProp: Int
|
||||
deinit
|
||||
}
|
||||
|
||||
public class TestEmptyClass {
|
||||
}
|
||||
|
||||
public struct TestEmptyStruct {
|
||||
}
|
||||
|
||||
public enum TestEnum {
|
||||
case a
|
||||
public init()
|
||||
public func method()
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
public var prop: Int { get set }
|
||||
public static var staticProp: Int
|
||||
}
|
||||
|
||||
public struct TestStruct {
|
||||
public init()
|
||||
public func method()
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
public var prop: Int { get set }
|
||||
public var storedProp: Int
|
||||
public static var staticProp: Int
|
||||
}
|
||||
|
||||
public let globalWithNoAccessors: Int
|
||||
public var readOnlyVar: Int { get }
|
||||
public var readWriteVar: Int { get set }
|
||||
public func verySimpleFunction()
|
||||
|
||||
// CHECK: sil [serialized] [exact_self_class] [canonical] @$s13SerializedSIL9TestClassCACycfC : $@convention(method) (@thick TestClass.Type) -> @owned TestClass {
|
||||
|
||||
// NEGATIVE-NOT: {{sil .*@.+storedProp}}
|
||||
|
||||
// NEGATIVE-NOT: sil_vtable
|
||||
// NEGATIVE-NOT: sil_witness_table
|
||||
@@ -0,0 +1,55 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name SystemDependencies
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: cp -r %S/Inputs/mock-sdk %t/mock-sdk
|
||||
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
|
||||
// RUN: test -f %t/MCP/SystemDependencies*.swiftmodule
|
||||
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/dummy.d
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SystemDependencies*.swiftmodule
|
||||
|
||||
// Baseline: running the same command again doesn't rebuild the cached module.
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SystemDependencies*.swiftmodule
|
||||
|
||||
// Now try changing the contents.
|
||||
// RUN: echo "// size change" >> %t/mock-sdk/usr/include/SomeCModule.h
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SystemDependencies*.swiftmodule
|
||||
|
||||
// Okay, now let's try again with system dependency tracking on.
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
|
||||
// RUN: test -f %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
// RUN: %FileCheck -check-prefix CHECK %s < %t/dummy.d
|
||||
// RUN: llvm-bcanalyzer -dump %t/MCP-system/SystemDependencies*.swiftmodule | %FileCheck -check-prefix CHECK-DUMP %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
|
||||
// Baseline: running the same command again doesn't rebuild the cached module.
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
|
||||
// Now try changing the contents.
|
||||
// RUN: echo "// size change" >> %t/mock-sdk/usr/include/SomeCModule.h
|
||||
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/MCP-system/SystemDependencies*.swiftmodule
|
||||
|
||||
// Check that it picked a different cache key.
|
||||
// RUN: %empty-directory(%t/MCP-combined)
|
||||
// RUN: cp %t/MCP/SystemDependencies*.swiftmodule %t/MCP-combined
|
||||
// RUN: cp %t/MCP-system/SystemDependencies*.swiftmodule %t/MCP-combined
|
||||
// RUN: ls -1 %t/MCP-combined | %FileCheck %s -check-prefix=MODULECACHE
|
||||
|
||||
// NEGATIVE-NOT: SomeCModule.h
|
||||
// CHECK: SomeCModule.h
|
||||
|
||||
// CHECK-DUMP-NOT: usr{{[/\\]}}include
|
||||
// CHECK-DUMP: DEPENDENCY_DIRECTORY{{.+}}'usr{{[/\\]}}include'
|
||||
// CHECK-DUMP-NEXT: FILE_DEPENDENCY{{.+}}'module.modulemap'
|
||||
// CHECK-DUMP-NOT: FILE_DEPENDENCY{{.+}}'SomeCModule.h'
|
||||
// CHECK-DUMP: FILE_DEPENDENCY{{.+}}'SomeCModule.h'
|
||||
// CHECK-DUMP-NOT: usr{{[/\\]}}include
|
||||
|
||||
// MODULECACHE-COUNT-2: SystemDependencies-{{[^ ]+}}.swiftmodule
|
||||
|
||||
import SomeCModule
|
||||
@@ -0,0 +1,7 @@
|
||||
// swift-interface-format-version: 1.0
|
||||
// swift-module-flags: -module-name DreadPirateRoberts
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: echo 'import WrongName' | not %target-swift-frontend -typecheck -module-cache-path %t -I %S - 2>&1 | %FileCheck %s
|
||||
|
||||
// CHECK: :1:8: error: cannot load module 'DreadPirateRoberts' as 'WrongName'
|
||||
@@ -0,0 +1,3 @@
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=garbage not %target-swift-frontend -typecheck %s 2>&1 | %FileCheck %s
|
||||
|
||||
// CHECK: error: unknown value for SWIFT_FORCE_MODULE_LOADING variable: 'garbage'
|
||||
@@ -0,0 +1,102 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1. Not finding things is okay.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
// 2. Only interface is present.
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 3. Only module is present.
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromSerialized/g' %S/Inputs/force-module-loading-mode/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/Lib.swiftmodule/%target-swiftmodule-name - -module-name Lib
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 4. Both are present.
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 5. Both are present but the module is invalid.
|
||||
// RUN: rm %t/Lib.swiftmodule/%target-swiftmodule-name && touch %t/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=BAD-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 6. Both are present but the module can't be opened.
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 7. Both are present but for the wrong architecture.
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: touch %t/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: touch %t/Lib.swiftmodule/garbage.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
|
||||
// 8. Only the interface is present but for the wrong architecture.
|
||||
// (Diagnostics for the module only are tested elsewhere.)
|
||||
// FIXME: We should improve this to not just say NO-SUCH-MODULE.
|
||||
// RUN: rm %t/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
import Lib
|
||||
// NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib'
|
||||
// BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule
|
||||
// WRONG-ARCH: [[@LINE-3]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: garbage
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-SERIALIZED: [[@LINE-2]]:16: error: cannot convert value of type 'FromSerialized' to specified type 'X'
|
||||
@@ -0,0 +1,103 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1. Not finding things is okay.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
// 2. Only interface is present.
|
||||
// RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 3. Only module is present.
|
||||
// RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromSerialized/g' %S/Inputs/force-module-loading-mode/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name - -module-name Lib
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
|
||||
// 4. Both are present.
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 5. Both are present but the module is invalid.
|
||||
// RUN: rm %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name && touch %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=BAD-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 6. Both are present but the module can't be opened.
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/Lib.framework/Modules/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 7. Both are present but for the wrong architecture.
|
||||
// RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: touch %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: touch %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftinterface
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%module-target-triple %s
|
||||
|
||||
// 8. Only the interface is present but for the wrong architecture.
|
||||
// (Diagnostics for the module only are tested elsewhere.)
|
||||
// FIXME: We should improve this to not just say NO-SUCH-MODULE.
|
||||
// RUN: rm %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
import Lib
|
||||
// NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib'
|
||||
// BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule
|
||||
// WRONG-ARCH: [[@LINE-3]]:8: error: could not find module 'Lib' for target '[[ARCH]]'; found: garbage
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-SERIALIZED: [[@LINE-2]]:16: error: cannot convert value of type 'FromSerialized' to specified type 'X'
|
||||
@@ -0,0 +1,77 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// 1. Not finding things is okay.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
|
||||
// 2. Only interface is present.
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %S/Inputs/force-module-loading-mode/ 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %S/Inputs/force-module-loading-mode/ %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// 3. Only module is present.
|
||||
// RUN: sed -e 's/FromInterface/FromSerialized/g' %S/Inputs/force-module-loading-mode/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
|
||||
// 4. Both are present.
|
||||
// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 5. Both are present but the module is invalid.
|
||||
// RUN: rm %t/Lib.swiftmodule && touch %t/Lib.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=BAD-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 6. Both are present but the module can't be opened.
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/Lib.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-parseable not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=only-serialized not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// (default)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
import Lib
|
||||
// NO-SUCH-MODULE: [[@LINE-1]]:8: error: no such module 'Lib'
|
||||
// BAD-MODULE: [[@LINE-2]]:8: error: malformed compiled module: {{.*}}Lib.swiftmodule
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-SERIALIZED: [[@LINE-2]]:16: error: cannot convert value of type 'FromSerialized' to specified type 'X'
|
||||
@@ -0,0 +1,56 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/mock-sdk)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
// RUN: %empty-directory(%t/PrebuiltModuleCache)
|
||||
|
||||
// This test makes sure that we propagate the right set of dependencies from a
|
||||
// prebuilt module to its corresponding forwarding module.
|
||||
|
||||
// Setup. Copy the mock SDK into the tmp directory.
|
||||
// RUN: cp -r %S/Inputs/mock-sdk/* %t/mock-sdk/.
|
||||
|
||||
// 1. Compile ExportedLib.swiftinterface, which a) is in the SDK, and b) depends
|
||||
// on a C module with headers that should be in the dependency list.
|
||||
// Put it in the prebuilt cache.
|
||||
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/mock-sdk/ExportedLib.swiftinterface -sdk %t/mock-sdk -o %t/PrebuiltModuleCache/ExportedLib.swiftmodule -serialize-parseable-module-interface-dependency-hashes -track-system-dependencies
|
||||
|
||||
// 2. Make sure the prebuilt module we built has SomeCModule.h as a dependency.
|
||||
|
||||
// RUN: llvm-bcanalyzer -dump %t/PrebuiltModuleCache/ExportedLib.swiftmodule | grep 'FILE_DEPENDENCY.*SomeCModule.h'
|
||||
|
||||
// 3. Typecheck this file, which imports SdkLib, which imports ExportedLib.
|
||||
// Because ExportedLib is prebuilt, we expect a forwarding module for
|
||||
// ExportedLib in the module cache, and a serialized module for SdkLib in
|
||||
// the cache.
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck %s -prebuilt-module-cache-path %t/PrebuiltModuleCache -module-cache-path %t/ModuleCache -sdk %t/mock-sdk -I %t/mock-sdk -track-system-dependencies
|
||||
|
||||
// 4. Make sure the forwarding module is installed in the cache.
|
||||
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/ModuleCache/ExportedLib-*.swiftmodule
|
||||
|
||||
// 5. Make sure the forwarding module depends on the prebuilt module and the C
|
||||
// header.
|
||||
|
||||
// RUN: grep ' *path:.*ExportedLib.swiftmodule' %t/ModuleCache/ExportedLib-*.swiftmodule
|
||||
// RUN: grep ' *path:.*SomeCModule.h' %t/ModuleCache/ExportedLib-*.swiftmodule
|
||||
|
||||
// 6. Make sure the dependencies from the forwarding module make it into the
|
||||
// cached module.
|
||||
|
||||
// RUN: llvm-bcanalyzer -dump %t/ModuleCache/SdkLib-*.swiftmodule | grep 'FILE_DEPENDENCY.*SomeCModule.h'
|
||||
|
||||
// 7. Make sure the prebuilt ExportedLib module did NOT get propagated to SdkLib.
|
||||
|
||||
// RUN: llvm-bcanalyzer -dump %t/ModuleCache/SdkLib-*.swiftmodule | not grep 'FILE_DEPENDENCY.*PrebuiltModuleCache'
|
||||
|
||||
// 8. Make sure we re-build the SdkLib module if one of the dependencies changes its mtime (but not its hash).
|
||||
// This will ensure we recorded the forwarding module's dependencies, not the prebuilt.
|
||||
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/ModuleCache/SdkLib-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/mock-sdk/usr/include/SomeCModule.h
|
||||
// RUN: %target-swift-frontend -typecheck %s -prebuilt-module-cache-path %t/PrebuiltModuleCache -module-cache-path %t/ModuleCache -sdk %t/mock-sdk -I %t/mock-sdk -track-system-dependencies
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/ModuleCache/SdkLib-*.swiftmodule
|
||||
|
||||
import SdkLib
|
||||
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Test will build a module TestModule that depends LeafModule (built from leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: test -f %t/LeafModule.swiftinterface
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-LEAFINTERFACE <%t/LeafModule.swiftinterface
|
||||
// CHECK-LEAFINTERFACE: {{swift-interface-format-version: [0-9\\.]+}}
|
||||
// CHECK-LEAFINTERFACE: LeafFunc
|
||||
//
|
||||
// Break LeafModule's version number
|
||||
// RUN: sed -e 's/swift-interface-format-version:.*/swift-interface-format-version: 9999.999/' %t/LeafModule.swiftinterface | tr -d '\r' > %t/LeafModule.swiftinterface.tmp
|
||||
// RUN: mv %t/LeafModule.swiftinterface.tmp %t/LeafModule.swiftinterface
|
||||
//
|
||||
// Try to build TestModule into a .swiftmodule explicitly using LeafModule via LeafModule.swiftinterface, but fail because version mismatch in LeafModule.swiftinterface.
|
||||
//
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err.txt 2>&1
|
||||
// RUN: test ! -f %t/TestModule.swiftmodule
|
||||
// This avoids a problem in Windows with test ! -f 'foo*' for a file that doesn't exist
|
||||
// RUN: %{python} -c "import sys; import glob; sys.exit(len(glob.glob('%t/modulecache/LeafModule-*.swiftmodule')) != 0)"
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-ERR <%t/err.txt
|
||||
// CHECK-ERR: {{error: unsupported version of module interface '.*[/\\]LeafModule.swiftinterface': '9999.999'}}
|
||||
// CHECK-ERR: error: no such module 'LeafModule
|
||||
|
||||
import LeafModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(LeafFunc())
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// This test specifically uses macOS deployment targets
|
||||
// REQUIRES: OS=macosx
|
||||
//
|
||||
// RUN: %empty-directory(%t)
|
||||
//
|
||||
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
// Phase 1: build LeafModule into a .swiftinterface file with -target x86_64-macosx-10.9:
|
||||
//
|
||||
// RUN: %swift -target x86_64-apple-macosx10.9 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck
|
||||
//
|
||||
// Phase 2: build OtherModule into a .swiftinterface file with -target x86_64-macosx-10.10:
|
||||
//
|
||||
// RUN: %swift -target x86_64-apple-macosx10.10 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -typecheck
|
||||
//
|
||||
// Phase 3: build TestModule in -target x86_64-apple-macosx10.11 and import both of these:
|
||||
//
|
||||
// RUN: %swift -target x86_64-apple-macosx10.11 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -typecheck
|
||||
//
|
||||
// Phase 4: make sure we only compiled LeafModule and OtherModule one time:
|
||||
//
|
||||
// RUN: NUM_LEAF_MODULES=$(find %t/modulecache -type f -name 'LeafModule-*.swiftmodule' | wc -l)
|
||||
// RUN: NUM_OTHER_MODULES=$(find %t/modulecache -type f -name 'OtherModule-*.swiftmodule' | wc -l)
|
||||
// RUN: if [ ! $NUM_LEAF_MODULES -eq 1 ]; then echo "Should only be 1 LeafModule, found $NUM_LEAF_MODULES"; exit 1; fi
|
||||
// RUN: if [ ! $NUM_OTHER_MODULES -eq 1 ]; then echo "Should only be 1 OtherModule, found $NUM_OTHER_MODULES"; exit 1; fi
|
||||
import LeafModule
|
||||
import OtherModule
|
||||
103
test/ModuleInterface/ModuleCache/module-cache-diagnostics.swift
Normal file
103
test/ModuleInterface/ModuleCache/module-cache-diagnostics.swift
Normal file
@@ -0,0 +1,103 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then revert LeafModule.swiftinterface to have a warning-provoking entry in it, and check that we get no diagnostic.
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface to have an error in it, and check that we get a diagnostic and failure.
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface to have an error in an @inlinable function body, and check we get a diagnostic and failure.
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: add an inlinable func with an unused var to LeafModule.swiftinterface (which should emit a warning); check we do get a rebuild, but no warning. (For astooscopelookup testing, must filter out that warning; see the sed command below.)
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: cp %t/LeafModule.swiftinterface %t/LeafModule.swiftinterface.backup
|
||||
// RUN: echo "@inlinable func foo() { var x = 10 }" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s 2>&1 | sed '/WARNING: TRYING Scope exclusively/d' >%t/warn.txt
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// "check warn.txt exists and is empty"
|
||||
// RUN: test -e %t/warn.txt -a ! -s %t/warn.txt
|
||||
//
|
||||
//
|
||||
// Next test: make LeafModule.swiftinterface import NotAModule (which should emit an error); check we do not get a rebuild, do get an error.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/*.swiftmodule %t/*.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: echo "import NotAModule" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err.txt 2>&1
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt
|
||||
// CHECK-ERROR: LeafModule.swiftinterface:7:8: error: no such module 'NotAModule'
|
||||
// CHECK-ERROR: OtherModule.swiftinterface:4:8: error: failed to load module 'LeafModule'
|
||||
// CHECK-ERROR: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to load module 'OtherModule'
|
||||
// CHECK-ERROR-NOT: error:
|
||||
//
|
||||
//
|
||||
// Next test: same as above, but with a .dia file
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -serialize-diagnostics -serialize-diagnostics-path %t/err.dia -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: c-index-test -read-diagnostics %t/err.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR
|
||||
//
|
||||
//
|
||||
// Next test: add an inlinable function body with an unresolved identifier to LeafModule.swiftinterface; check we do not get a rebuild and report the additional error correctly.
|
||||
//
|
||||
// RUN: mv %t/LeafModule.swiftinterface.backup %t/LeafModule.swiftinterface
|
||||
// RUN: echo "@inlinable func bar() { var x = unresolved }" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err-inline.txt 2>&1
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt
|
||||
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:6:33: error: use of unresolved identifier 'unresolved'
|
||||
// CHECK-ERROR-INLINE: OtherModule.swiftinterface:4:8: error: failed to load module 'LeafModule'
|
||||
// CHECK-ERROR-INLINE: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to load module 'OtherModule'
|
||||
// CHECK-ERROR-INLINE-NOT: error:
|
||||
//
|
||||
//
|
||||
// Next test: same as above, but with a .dia file
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -serialize-diagnostics -serialize-diagnostics-path %t/err-inline.dia -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: c-index-test -read-diagnostics %t/err-inline.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR-INLINE
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
//
|
||||
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
// Phase 1: build LeafModule into a .swiftinterface file with -swift-version 4:
|
||||
//
|
||||
// RUN: %target-swift-frontend -swift-version 4 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck
|
||||
//
|
||||
// Phase 2: build OtherModule into a .swiftinterface file with -swift-version 4.2:
|
||||
//
|
||||
// RUN: %target-swift-frontend -swift-version 4.2 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -typecheck
|
||||
//
|
||||
// Phase 3: build TestModule in -swift-version 5 and import both of these:
|
||||
//
|
||||
// RUN: %target-swift-frontend -swift-version 5 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -typecheck
|
||||
//
|
||||
// Phase 4: make sure we only compiled LeafModule and OtherModule one time:
|
||||
//
|
||||
// RUN: ls %t/modulecache | grep -c 'LeafModule-.*.swiftmodule' | %FileCheck %s
|
||||
// RUN: ls %t/modulecache | grep -c 'OtherModule-.*.swiftmodule' | %FileCheck %s
|
||||
// CHECK: 1
|
||||
|
||||
import LeafModule
|
||||
import OtherModule
|
||||
@@ -0,0 +1,23 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a parseable interface for a module SomeModule (built from some-module.swift).
|
||||
// This test checks we still build and load its corresponding .swiftmodule when the file that imports it contains an error prior to the import statement.
|
||||
|
||||
// Setup phase 1: Write the input file.
|
||||
//
|
||||
// RUN: echo 'public func SomeFunc() -> Int { return 42; }' >>%t/some-module.swift
|
||||
|
||||
// Setup phase 2: build the module.
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/SomeModule.swiftinterface -module-name SomeModule %t/some-module.swift -emit-module -o /dev/null
|
||||
|
||||
// Actual test: compile and verify the import succeeds (i.e. we only report the error in this file)
|
||||
//
|
||||
// RUN: %target-swift-frontend -typecheck -verify -I %t -module-cache-path %t/modulecache %s
|
||||
|
||||
unresolved // expected-error {{use of unresolved identifier 'unresolved'}}
|
||||
|
||||
import SomeModule
|
||||
|
||||
print(SomeFunc())
|
||||
72
test/ModuleInterface/ModuleCache/module-cache-init.swift
Normal file
72
test/ModuleInterface/ModuleCache/module-cache-init.swift
Normal file
@@ -0,0 +1,72 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
//
|
||||
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
// Phase 1: build LeafModule into a .swiftinterface file:
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: test -f %t/LeafModule.swiftinterface
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-LEAFINTERFACE <%t/LeafModule.swiftinterface
|
||||
// CHECK-LEAFINTERFACE: LeafFunc
|
||||
//
|
||||
//
|
||||
// Phase 2: build OtherModule into a .swiftinterface _using_ LeafModule via LeafModule.swiftinterface, creating LeafModule-*.swiftmodule along the way.
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: test -f %t/OtherModule.swiftinterface
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-OTHERINTERFACE <%t/OtherModule.swiftinterface
|
||||
// CHECK-OTHERINTERFACE: OtherFunc
|
||||
// RUN: test -f %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: llvm-bcanalyzer -dump %t/modulecache/LeafModule-*.swiftmodule | %FileCheck %s -check-prefix=CHECK-LEAFMODULE
|
||||
// CHECK-LEAFMODULE: {{MODULE_NAME.*blob data = 'LeafModule'}}
|
||||
// CHECK-LEAFMODULE: {{FILE_DEPENDENCY.*LeafModule.swiftinterface'}}
|
||||
// CHECK-LEAFMODULE: FUNC_DECL
|
||||
// RUN: llvm-bcanalyzer -dump %t/modulecache/LeafModule-*.swiftmodule | %FileCheck %s -check-prefix=CHECK-LEAFMODULE-NEGATIVE
|
||||
// CHECK-LEAFMODULE-NEGATIVE-NOT: {{FILE_DEPENDENCY.*Swift.swiftmodule([/\\].+[.]swiftmodule)?'}}
|
||||
//
|
||||
//
|
||||
// Phase 3: build TestModule into a .swiftmodule explicitly us OtherModule via OtherModule.swiftinterface, creating OtherModule-*.swiftmodule along the way.
|
||||
//
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -emit-dependencies -emit-dependencies-path %t/TestModule.d -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: test -f %t/TestModule.swiftmodule
|
||||
// RUN: test -f %t/modulecache/OtherModule-*.swiftmodule
|
||||
// RUN: test -f %t/TestModule.d
|
||||
// RUN: llvm-bcanalyzer -dump %t/modulecache/OtherModule-*.swiftmodule | %FileCheck %s -check-prefix=CHECK-OTHERMODULE
|
||||
// CHECK-OTHERMODULE: {{MODULE_NAME.*blob data = 'OtherModule'}}
|
||||
// CHECK-OTHERMODULE-NOT: {{FILE_DEPENDENCY.*Swift.swiftmodule([/\\].+[.]swiftmodule)?'}}
|
||||
// CHECK-OTHERMODULE: {{FILE_DEPENDENCY.*LeafModule.swiftinterface'}}
|
||||
// CHECK-OTHERMODULE: {{FILE_DEPENDENCY.*OtherModule.swiftinterface'}}
|
||||
// CHECK-OTHERMODULE: FUNC_DECL
|
||||
//
|
||||
// Quirk: because the cached .swiftmodules have a hash name component that
|
||||
// integrates target, and we sort the contents of lines in a .d file by the
|
||||
// dependency's reverse-name (for reasons), the order in which the cached
|
||||
// .swiftmodules are listed in the .d file will vary _by target_.
|
||||
//
|
||||
// So we cannot write a single set of CHECK-SAME lines here that will work
|
||||
// for all targets: some will have LeafModule first, some OtherModule
|
||||
// first. So instead we just use CHECK-DAG.
|
||||
//
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-DEPENDS <%t/TestModule.d
|
||||
//
|
||||
// CHECK-DEPENDS: TestModule.swiftmodule :
|
||||
// CHECK-DEPENDS-DAG: LeafModule.swiftinterface
|
||||
// CHECK-DEPENDS-DAG: OtherModule.swiftinterface
|
||||
// CHECK-DEPENDS-DAG: Swift.swiftmodule
|
||||
// CHECK-DEPENDS-DAG: SwiftOnoneSupport.swiftmodule
|
||||
//
|
||||
// RUN: %FileCheck %s -check-prefix=CHECK-DEPENDS-NEGATIVE <%t/TestModule.d
|
||||
//
|
||||
// CHECK-DEPENDS-NEGATIVE-NOT: {{LeafModule-[^ ]+.swiftmodule}}
|
||||
// CHECK-DEPENDS-NEGATIVE-NOT: {{OtherModule-[^ ]+.swiftmodule}}
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify OtherModule.swiftinterface's content (but not size), and check only OtherModule-*.swiftmodule has a new mtime, LeafModule is unchanged.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc2() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: Change the mtime of OtherModule.swiftinterface, check we only rebuild its cached module.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: touch %t/OtherModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify OtherModule.swiftinterface's size (but not mtime), and check only OtherModule-*.swiftmodule has a new mtime, LeafModule is unchanged.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: make OtherModule.swiftinterface change size without changing mtime, check we only rebuild its cached module.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: echo "// size change" >>%t/OtherModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/OtherModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface's content (but not size), and check both cached modules have new mtimes.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
// RUN: echo 'public func LeafFunc2() -> Int { return 11; }' >>%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: Change the mtime of LeafModule.swiftinterface, check both cached modules get rebuilt.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: touch %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then modify LeafModule.swiftinterface's size (but not mtime), and check both cached modules have new mtimes.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: make LeafModule.swiftinterface change size without changing mtime, check both cached modules get rebuilt.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: echo "// size change" >>%t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/modulecache)
|
||||
//
|
||||
// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
|
||||
// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past).
|
||||
//
|
||||
// We then rebuild TestModule a second time, without changing any inputs, and confirm none of the files has a new mtime.
|
||||
//
|
||||
//
|
||||
// Setup phase 1: Write input files.
|
||||
//
|
||||
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
|
||||
//
|
||||
// RUN: echo 'import LeafModule' >%t/other.swift
|
||||
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
|
||||
//
|
||||
//
|
||||
// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/leaf.swift %t/other.swift
|
||||
// RUN: %target-swift-frontend -I %t -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule
|
||||
//
|
||||
//
|
||||
// Actual test: rebuild output, check no intermediates gets rebuilt.
|
||||
//
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
// RUN: rm %t/TestModule.swiftmodule
|
||||
// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
|
||||
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
|
||||
|
||||
import OtherModule
|
||||
|
||||
public func TestFunc() {
|
||||
print(OtherFunc())
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/include/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
|
||||
// Baseline check: if the prebuilt cache path does not exist, everything should
|
||||
// still work.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Baseline check: if the module is not in the prebuilt cache, build it
|
||||
// normally.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Do a manual prebuild, and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// What if the module is invalid?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name && touch %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// What if the arch is missing?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,45 @@
|
||||
// Like prebuilt-module-cache-archs.swift, but testing the fallback behavior.
|
||||
// This means we have to know the expected names in advance, so this test only
|
||||
// runs on macOS.
|
||||
|
||||
// REQUIRES: OS=macosx
|
||||
// REQUIRES: CPU=x86_64
|
||||
|
||||
// Use the short name "x86_64.swiftmodule".
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/include/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/x86_64.swiftinterface
|
||||
|
||||
// Do a manual prebuild with the long name "x86_64-apple-macos.swiftmodule",
|
||||
// and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuiltLong/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/x86_64-apple-macos.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT-LONG %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Prefer a matching name.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuiltShort/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule/x86_64.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT-SHORT %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Prefer a matching name in the other direction too.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: mv %t/include/Lib.swiftmodule/x86_64.swiftinterface %t/include/Lib.swiftmodule/x86_64-apple-macos.swiftinterface
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT-LONG %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Don't do the fallback thing for long names to short names.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule/x86_64-apple-macos.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %t/include -I %t/include/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT-LONG: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuiltLong' to specified type 'X'
|
||||
// FROM-PREBUILT-SHORT: [[@LINE-3]]:16: error: cannot convert value of type 'FromPrebuiltShort' to specified type 'X'
|
||||
@@ -0,0 +1,52 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
|
||||
// First, prebuild a module and put it in the prebuilt cache.
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | tr -d '\r' > %t/Lib.swiftinterface.tmp
|
||||
// RUN: mv %t/Lib.swiftinterface.tmp %t/Lib.swiftinterface
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface -module-cache-path %t/MCP -serialize-parseable-module-interface-dependency-hashes -o %t/prebuilt-cache/Lib.swiftmodule %t/Lib.swiftinterface
|
||||
|
||||
// Next, use the module and check if the forwarding module is in place.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
// RUN: cat %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Now invalidate a dependency of the prebuilt module, by changing the hash of the .swiftinterface.
|
||||
// RUN: cp %t/Lib.swiftinterface %t/Lib.swiftinterface.moved-aside
|
||||
// RUN: echo ' ' >> %t/Lib.swiftinterface
|
||||
|
||||
// Make sure the forwarding file is replaced with a real module.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Delete the cached module we just created, put the old .swiftinterface back, and create the forwarding module again
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: mv %t/Lib.swiftinterface.moved-aside %t/Lib.swiftinterface
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Move the prebuilt module out of the way, so the forwarding module points to nothing.
|
||||
// RUN: mv %t/prebuilt-cache/Lib.swiftmodule %t/prebuilt-cache/NotLib.swiftmodule
|
||||
|
||||
// Make sure we delete the existing forwarding module and rebuild from an interface.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Move the prebuilt module back to its original path
|
||||
// RUN: mv %t/prebuilt-cache/NotLib.swiftmodule %t/prebuilt-cache/Lib.swiftmodule
|
||||
|
||||
// If the forwarding module is corrupted, we shouldn't rebuild the module in the cache,
|
||||
// we should delete it and generate a new forwarding module.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
// RUN: %{python} %S/../Inputs/make-unreadable.py %t/MCP/Lib-*.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,13 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Create a prebuilt module cache and populate it with a prebuilt module.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: %target-swift-frontend -parse-stdlib %S/Inputs/prebuilt-module-cache/Lib.swiftinterface -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
|
||||
// Compile against the module with a module cache that does not exist
|
||||
// RUN: %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/RandomPath/NonExistentCachePath -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache -prebuilt-module-cache-path %t/prebuilt-cache %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/RandomPath/NonExistentCachePath/Lib-*.swiftmodule
|
||||
|
||||
import Lib
|
||||
@@ -0,0 +1,25 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Baseline check: if the module is not in the prebuilt cache, build it
|
||||
// normally.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Do a manual prebuild, and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// What if the module is invalid?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule && touch %t/prebuilt-cache/Lib.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/ -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
import LibExporter
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,28 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// -- construct prebuilt
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// -- generate a manual prebuilt
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | tr -d '\r' | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// -- ensure we installed a forwarding module
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// -- ensure that the search path is in the root
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk / -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// This test is not supported on Windows since the root is not / but rather a
|
||||
// drive letter followed by a colon.
|
||||
// UNSUPPORTED: OS=windows-msvc
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
|
||||
// FROM-INTERFACE: [[@LINE-2]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-3]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/include/Lib.swiftmodule)
|
||||
// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
|
||||
// Prebuild a module for the current target CPU, and put it in the prebuilt cache under some imaginary CPU.
|
||||
// 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
|
||||
|
||||
// Make sure that, if there's a module for a different architecture
|
||||
// present in the prebuilt cache, it's ignored and the module is
|
||||
// rebuilt from an interface.
|
||||
|
||||
// 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
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// Make sure it works fine if the module is for this architecture.
|
||||
// RUN: mv %t/prebuilt-cache/Lib.swiftmodule/leg128.swiftmodule %t/prebuilt-cache/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// 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
|
||||
|
||||
// Now make sure it works if there's nothing in the prebuilt cache
|
||||
// RUN: %empty-directory(%t/prebuilt-cache/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
|
||||
// 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
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-PREBUILT: [[@LINE-1]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
// FROM-INTERFACE: [[@LINE-2]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
38
test/ModuleInterface/ModuleCache/prebuilt-module-cache.swift
Normal file
38
test/ModuleInterface/ModuleCache/prebuilt-module-cache.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// Baseline check: if the prebuilt cache path does not exist, everything should
|
||||
// still work.
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Baseline check: if the module is not in the prebuilt cache, build it
|
||||
// normally.
|
||||
// RUN: %empty-directory(%t/prebuilt-cache)
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// Do a manual prebuild, and see if it gets picked up.
|
||||
// RUN: %empty-directory(%t/MCP)
|
||||
// RUN: sed -e 's/FromInterface/FromPrebuilt/g' %S/Inputs/prebuilt-module-cache/Lib.swiftinterface | tr -d '\r' | %target-swift-frontend -parse-stdlib -module-cache-path %t/MCP -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// Make sure we installed a forwarding module.
|
||||
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/Lib-*.swiftmodule
|
||||
|
||||
// Try some variations on the detection that the search path is in the SDK:
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S//Inputs -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/prebuilt-module-cache -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-PREBUILT %s
|
||||
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/p -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/garbage-path -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk "" -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
// What if the module is invalid?
|
||||
// RUN: rm %t/prebuilt-cache/Lib.swiftmodule && touch %t/prebuilt-cache/Lib.swiftmodule
|
||||
// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -sdk %S/Inputs/ -I %S/Inputs/prebuilt-module-cache/ -prebuilt-module-cache-path %t/prebuilt-cache %s 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
|
||||
|
||||
import Lib
|
||||
|
||||
struct X {}
|
||||
let _: X = Lib.testValue
|
||||
// FROM-INTERFACE: [[@LINE-1]]:16: error: cannot convert value of type 'FromInterface' to specified type 'X'
|
||||
// FROM-PREBUILT: [[@LINE-2]]:16: error: cannot convert value of type 'FromPrebuilt' to specified type 'X'
|
||||
@@ -0,0 +1,31 @@
|
||||
// RUN: %empty-directory(%t/BuildDir/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/SecondBuildDir/Lib.framework/Modules/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
|
||||
// RUN: echo 'public func showsUpInBothPlaces() {}' > %t/Lib.swift
|
||||
|
||||
// 1. Create a .swiftinterface file containing just one API, and put it inside a second build dir (without a .swiftmodule)
|
||||
// RUN: %target-swift-frontend -typecheck %t/Lib.swift -emit-module-interface-path %t/SecondBuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface -module-name Lib
|
||||
|
||||
// 2. Add a new API to the module, and compile just the serialized version in the build dir.
|
||||
// RUN: echo 'public func onlyInTheCompiledModule() {}' >> %t/Lib.swift
|
||||
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -o %t/BuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftmodule -emit-module-interface-path %t/BuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface -module-name Lib
|
||||
|
||||
// 3. Make sure when we compile this test file, we can access both APIs since we'll
|
||||
// load the compiled .swiftmodule instead of the .swiftinterface in the SDK.
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %t/BuildDir -F %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 4. Make sure we didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
// 5. This should also work if the swiftinterface isn't present in the first build dir.
|
||||
// RUN: rm %t/BuildDir/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %t/BuildDir -F %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 6. Make sure we /still/ didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
import Lib
|
||||
|
||||
showsUpInBothPlaces()
|
||||
onlyInTheCompiledModule()
|
||||
@@ -0,0 +1,31 @@
|
||||
// RUN: %empty-directory(%t/BuildDir)
|
||||
// RUN: %empty-directory(%t/SecondBuildDir/Lib.swiftmodule)
|
||||
// RUN: %empty-directory(%t/ModuleCache)
|
||||
|
||||
// RUN: echo 'public func showsUpInBothPlaces() {}' > %t/Lib.swift
|
||||
|
||||
// 1. Create a .swiftinterface file containing just one API, and put it inside a second build dir (without a .swiftmodule)
|
||||
// RUN: %target-swift-frontend -typecheck %t/Lib.swift -emit-module-interface-path %t/SecondBuildDir/Lib.swiftmodule/%target-cpu.swiftinterface -module-name Lib
|
||||
|
||||
// 2. Add a new API to the module, and compile just the serialized version in the build dir.
|
||||
// RUN: echo 'public func onlyInTheCompiledModule() {}' >> %t/Lib.swift
|
||||
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -o %t/BuildDir/Lib.swiftmodule -emit-module-interface-path %t/BuildDir/Lib.swiftinterface
|
||||
|
||||
// 3. Make sure when we compile this test file, we can access both APIs since we'll
|
||||
// load the compiled .swiftmodule instead of the .swiftinterface in the SDK.
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/BuildDir -I %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 4. Make sure we didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
// 5. This should also work if the swiftinterface isn't present in the first build dir.
|
||||
// RUN: rm %t/BuildDir/Lib.swiftinterface
|
||||
// RUN: %target-swift-frontend -typecheck %s -I %t/BuildDir -I %t/SecondBuildDir -module-cache-path %t/ModuleCache
|
||||
|
||||
// 6. Make sure we /still/ didn't compile any .swiftinterfaces into the module cache.
|
||||
// RUN: ls %t/ModuleCache | not grep 'swiftmodule'
|
||||
|
||||
import Lib
|
||||
|
||||
showsUpInBothPlaces()
|
||||
onlyInTheCompiledModule()
|
||||
@@ -0,0 +1,25 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module -emit-module-interface-path %t/Lib.swiftinterface -emit-module-doc -parse-stdlib -o %t/Lib.swiftmodule %s
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-module.txt
|
||||
// RUN: %FileCheck %s < %t/from-module.txt
|
||||
|
||||
// RUN: rm %t/Lib.swiftmodule
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-interface.txt
|
||||
// RUN: diff %t/from-module.txt %t/from-interface.txt
|
||||
|
||||
// Try again with architecture-specific subdirectories.
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %empty-directory(%t/Lib.swiftmodule)
|
||||
// RUN: %target-swift-frontend -emit-module -emit-module-interface-path %t/Lib.swiftmodule/%target-cpu.swiftinterface -emit-module-doc -parse-stdlib -o %t/Lib.swiftmodule/%target-swiftmodule-name -module-name Lib %s
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-module.txt
|
||||
// RUN: %FileCheck %s < %t/from-module.txt
|
||||
|
||||
// RUN: rm %t/Lib.swiftmodule/%target-swiftmodule-name
|
||||
// RUN: env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x -prefer-type-repr=false -fully-qualified-types=true > %t/from-interface.txt
|
||||
// RUN: diff %t/from-module.txt %t/from-interface.txt
|
||||
|
||||
/// Very important documentation!
|
||||
public struct SomeStructWithDocumentation {}
|
||||
|
||||
// CHECK: Very important documentation!
|
||||
// CHECK-NEXT: struct SomeStructWithDocumentation {
|
||||
Reference in New Issue
Block a user