Skip to content

Commit d3dbe75

Browse files
committed
ModuleInterface: Introduce the %target-swift-emit-module-interface and %target-swift-typecheck-module-from-interface lit substitutions and adopt them in some tests that involve emitting a swiftinterface. The substitutions specify the additional flags -swift-version 5 -enable-library-evolution. There are a few motivations for adding these substitutions:
- Tests that depend on emitted interfaces should generally use flags that are typical for modules that have textual interfaces (e.g. `-enable-library-evolution`). - If a test is intended to produce a valid `swiftinterface` then it should verify that interface. This will help prevent interface printing regressions caused by compiler changes. - Having commonly used substitutions for tests that emit interfaces makes it easy to experiment with compiler flags that might effect interface printing. Resolves rdar://91634358
1 parent cc0627a commit d3dbe75

File tree

6 files changed

+27
-4
lines changed

6 files changed

+27
-4
lines changed

docs/Testing.md

+11
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,17 @@ code for the target that is not the build machine:
338338
* ``%target-swift-autolink-extract``: run ``swift-autolink-extract`` for the
339339
target to extract its autolink flags on platforms that support them (when the
340340
autolink-extract feature flag is set)
341+
342+
* ``%target-swift-emit-module-interface(`` *swift interface path* ``)``
343+
*other arguments*: run ``swift-frontend`` for the target, emitting a
344+
swiftinterface to the given path and passing additional default flags
345+
appropriate for resilient frameworks.
346+
347+
* ``%target-swift-typecheck-module-from-interface(`` *swift interface path*
348+
``)`` *other arguments*: run ``swift-frontend`` for the target, verifying
349+
the swiftinterface at the given path and passing additional default flags
350+
appropriate for resilient frameworks. Designed to be used in combination with
351+
``%target-swift-emit-module-interface()``.
341352

342353
* ``%target-clang``: run the system's ``clang++`` for the target.
343354

test/AutoDiff/ModuleInterface/differentiation.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface -enable-library-evolution %s
1+
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s
2+
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface)
23
// RUN: %FileCheck %s < %t.swiftinterface
34

45
import _Differentiation

test/ModuleInterface/attrs.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t.swiftinterface -enable-library-evolution %s
1+
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name attrs
2+
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name attrs
23
// RUN: %FileCheck %s < %t.swiftinterface
34

45
// CHECK: @_transparent public func glass() -> Swift.Int { return 0 }{{$}}

test/ModuleInterface/conformances.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-swift-frontend-typecheck -emit-module-interface-path %t.swiftinterface %s
1+
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name conformances
2+
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name conformances
23
// RUN: %FileCheck %s < %t.swiftinterface
34
// RUN: %FileCheck -check-prefix CHECK-END %s < %t.swiftinterface
45
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t.swiftinterface

test/ModuleInterface/full-convention.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -swift-version 5 -emit-module-interface-path - -enable-library-evolution %s -experimental-print-full-convention -use-clang-function-types | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -swift-version 5 -emit-module-interface-path %t/full-convention.swiftinterface -enable-library-evolution %s -experimental-print-full-convention -use-clang-function-types
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck-module-from-interface %t/full-convention.swiftinterface
4+
// RUN: %FileCheck %s < %t/full-convention.swiftinterface
25

36
import ctypes
47

test/lit.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,12 @@ config.substitutions.append(('%target-pic-opt', config.target_pic_opt))
22592259
config.substitutions.append(('%target-msvc-runtime-opt',
22602260
config.target_msvc_runtime_opt))
22612261

2262+
config.substitutions.append(('%target-swift-emit-module-interface\(([^)]+)\)',
2263+
SubstituteCaptures(r'%target-swift-frontend -swift-version 5 -enable-library-evolution -typecheck -emit-module-interface-path \1')))
2264+
2265+
config.substitutions.append(('%target-swift-typecheck-module-from-interface\(([^)]+)\)',
2266+
SubstituteCaptures(r'%target-swift-frontend -swift-version 5 -enable-library-evolution -typecheck-module-from-interface \1')))
2267+
22622268
config.substitutions.append(('%target-typecheck-verify-swift', config.target_parse_verify_swift))
22632269

22642270
config.substitutions.append(('%target-swift-emit-silgen\(mock-sdk:([^)]+)\)',

0 commit comments

Comments
 (0)