Files
swift-mirror/test/ParseableInterface/ModuleCache/module-cache-bad-version.swift
Daniel Rodríguez Troitiño 86eddd481e [windows] Fix module-cache-bad-version.swift in Windows.
In Windows, the expansion of globs is not perform by the shell, and
might happen or not in each process. Seems that some versions of `test`
(like the one used in CI) do their own expansion. Since the test is
testing for the inexistence of a file, the asterisk ends up in the
process argv, then the expansion happen, which finds no files, and test
fails saying that -f needs an argument. This doesn't happen in Unix
because the asterisk is not expanded in process.

Quoting or other tricks were defeated by lit own parsing of the
commands.

The solution involves using Python own globbing to find out if there's a
file that matches the glob or not.
2019-05-31 18:05:33 -07:00

33 lines
1.8 KiB
Swift

// 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-parseable-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())
}