Skip to content

Commit 0a04b4b

Browse files
author
Nathan Hawes
committed
[ParseableInterface] Add diagnostics test for errors in inlinable function bodies
Adds a test that errors reported in the inlinable function bodies of .swiftinterface files are propagated correctly when generating the corresponding .swiftmodule files. rdar://problem/44400260
1 parent 4ee879e commit 0a04b4b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/ParseableInterface/ModuleCache/module-cache-diagnostics.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// We then modify LeafModule.swiftinterface to have an error in it, and check that we get a diagnostic and failure.
1010
//
11+
// We then modify LeafModule.swiftinterface to have an error in an @inlinable function body, and check we get a diagnostic and failure.
1112
//
1213
// Setup phase 1: Write input files.
1314
//
@@ -32,6 +33,7 @@
3233
//
3334
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
3435
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
36+
// RUN: cp %t/LeafModule.swiftinterface %t/LeafModule.swiftinterface.backup
3537
// RUN: echo "@inlinable func foo() { var x = 10 }" >>%t/LeafModule.swiftinterface
3638
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
3739
// RUN: %{python} %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface
@@ -65,6 +67,29 @@
6567
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -serialize-diagnostics -serialize-diagnostics-path %t/err.dia -enable-parseable-module-interface -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
6668
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
6769
// RUN: c-index-test -read-diagnostics %t/err.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR
70+
//
71+
//
72+
// 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.
73+
//
74+
// RUN: mv %t/LeafModule.swiftinterface.backup %t/LeafModule.swiftinterface
75+
// RUN: echo "@inlinable func bar() { var x = unresolved }" >>%t/LeafModule.swiftinterface
76+
// RUN: %{python} %S/Inputs/make-old.py %t/LeafModule.swiftinterface
77+
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
78+
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
79+
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -enable-parseable-module-interface -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err-inline.txt 2>&1
80+
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
81+
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt
82+
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:6:33: error: use of unresolved identifier 'unresolved'
83+
// CHECK-ERROR-INLINE: OtherModule.swiftinterface:4:8: error: no such module 'LeafModule'
84+
//
85+
//
86+
// Next test: same as above, but with a .dia file
87+
//
88+
// RUN: %{python} %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface
89+
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
90+
// RUN: not %target-swift-frontend -I %t -module-cache-path %t/modulecache -serialize-diagnostics -serialize-diagnostics-path %t/err-inline.dia -enable-parseable-module-interface -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s
91+
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
92+
// RUN: c-index-test -read-diagnostics %t/err-inline.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR-INLINE
6893

6994
import OtherModule
7095

0 commit comments

Comments
 (0)