|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %empty-directory(%t/modulecache) |
| 3 | +// |
| 4 | +// Setup builds a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift). |
| 5 | +// During setup, input and intermediate mtimes are all set to a constant 'old' time (long in the past). |
| 6 | +// |
| 7 | +// We then revert LeafModule.swiftinterface to have a warning-provoking entry in it, and check that we get no diagnostic. |
| 8 | +// |
| 9 | +// We then modify LeafModule.swiftinterface to have an error in it, and check that we get a diagnostic and failure. |
| 10 | +// |
| 11 | +// |
| 12 | +// Setup phase 1: Write input files. |
| 13 | +// |
| 14 | +// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift |
| 15 | +// |
| 16 | +// RUN: echo 'import LeafModule' >%t/other.swift |
| 17 | +// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift |
| 18 | +// |
| 19 | +// |
| 20 | +// Setup phase 2: build modules, pushing timestamps of inputs and intermediates into the past as we go. |
| 21 | +// |
| 22 | +// RUN: %S/Inputs/make-old.py %t/leaf.swift %t/other.swift |
| 23 | +// RUN: %target-swift-frontend -I %t -emit-parseable-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -emit-module -o /dev/null |
| 24 | +// RUN: %S/Inputs/make-old.py %t/LeafModule.swiftinterface |
| 25 | +// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -enable-parseable-module-interface -emit-parseable-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null |
| 26 | +// RUN: %S/Inputs/make-old.py %t/modulecache/LeafModule-*.swiftmodule %t/OtherModule.swiftinterface |
| 27 | +// RUN: %target-swift-frontend -I %t -module-cache-path %t/modulecache -enable-parseable-module-interface -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s |
| 28 | +// RUN: %S/Inputs/make-old.py %t/modulecache/OtherModule-*.swiftmodule |
| 29 | +// |
| 30 | +// |
| 31 | +// 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. |
| 32 | +// |
| 33 | +// RUN: %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface |
| 34 | +// RUN: %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule |
| 35 | +// RUN: echo "@inlinable func foo() { var x = 10 }" >>%t/LeafModule.swiftinterface |
| 36 | +// RUN: %S/Inputs/make-old.py %t/LeafModule.swiftinterface |
| 37 | +// RUN: %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface |
| 38 | +// RUN: rm %t/TestModule.swiftmodule |
| 39 | +// RUN: %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/warn.txt 2>&1 |
| 40 | +// RUN: %S/Inputs/check-is-new.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule |
| 41 | +// "check warn.txt exists and is empty" |
| 42 | +// RUN: test -e %t/warn.txt -a ! -s %t/warn.txt |
| 43 | +// |
| 44 | +// |
| 45 | +// Next test: make LeafModule.swiftinterface import NotAModule (which should emit an error); check we do not get a rebuild, do get an error. |
| 46 | +// |
| 47 | +// RUN: %S/Inputs/make-old.py %t/modulecache/*.swiftmodule %t/*.swiftinterface |
| 48 | +// RUN: %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface |
| 49 | +// RUN: %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule |
| 50 | +// RUN: echo "import NotAModule" >>%t/LeafModule.swiftinterface |
| 51 | +// RUN: %S/Inputs/make-old.py %t/LeafModule.swiftinterface |
| 52 | +// RUN: %S/Inputs/check-is-old.py %t/LeafModule.swiftinterface |
| 53 | +// RUN: rm %t/TestModule.swiftmodule |
| 54 | +// 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.txt 2>&1 |
| 55 | +// RUN: %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule |
| 56 | +// RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt |
| 57 | +// CHECK-ERROR: LeafModule.swiftinterface:5:8: error: no such module 'NotAModule' |
| 58 | +// CHECK-ERROR: OtherModule.swiftinterface:3:8: error: no such module 'LeafModule' |
| 59 | +// |
| 60 | +// |
| 61 | +// Next test: same as above, but with a .dia file |
| 62 | +// |
| 63 | +// RUN: %S/Inputs/check-is-old.py %t/OtherModule.swiftinterface %t/LeafModule.swiftinterface |
| 64 | +// RUN: %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule |
| 65 | +// 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 |
| 66 | +// RUN: %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule |
| 67 | +// RUN: c-index-test -read-diagnostics %t/err.dia 2>&1 | %FileCheck %s -check-prefix=CHECK-ERROR |
| 68 | + |
| 69 | +import OtherModule |
| 70 | + |
| 71 | +public func TestFunc() { |
| 72 | + print(OtherFunc()) |
| 73 | +} |
| 74 | + |
0 commit comments