Skip to content

Commit 80cd48d

Browse files
committed
[windows] Fix ParseableInterface tests.
There were several Unix specific things in the ParseableInterface tests: the Bash subcommand was used, a Python tool was invoked without an explicit interpreter, and Unix path separators are used in CHECK lines. The Bash subcommand is replaced by a Lit substitution. Both swiftmodule and swiftdoc had substitutions, so swiftinterface gets one which should about the subcommand. The Python tool is invoked with an explicit interpreter. The Unix paths, instead of adding the ugly {{\\|/}} pattern everywhere are fixed in the PathSanitizing tool instead, that gets a new capability in Windows compatibility mode where all the Windows path found in the input are transformed into Windows path with only forward slashes (Unix slashes) in the output, which can be checked textually against the CHECK lines.
1 parent 194dba6 commit 80cd48d

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

test/ParseableInterface/swift_build_sdk_interfaces/check-only-mode.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
33
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
44

5-
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name Normal
5+
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-cpu.swiftinterface -emit-module -o /dev/null -module-name Normal
66
// RUN: echo 'public func flat() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Flat.swiftinterface -emit-module -o /dev/null -module-name Flat
7-
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name FMWK
7+
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/%target-cpu.swiftinterface -emit-module -o /dev/null -module-name FMWK
88

99
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -v -o %t/prebuilt -check-only
1010
// RUN: ls %t/prebuilt | %FileCheck %s
@@ -18,7 +18,7 @@
1818
// Touch a file in the SDK (to make it look like it changed) and try again.
1919
// In -check-only mode, this should force a rebuild.
2020
// RUN: rm -rf %t/MCP
21-
// RUN: %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
21+
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-cpu.swiftinterface
2222
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
2323
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule
2424

test/ParseableInterface/swift_build_sdk_interfaces/compiler-uses-prebuilt.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// RUN: mkdir -p %t/sdk/usr/lib/swift/Normal.swiftmodule
33
// RUN: mkdir -p %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule
44

5-
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name Normal
5+
// RUN: echo 'public func normal() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-cpu.swiftinterface -emit-module -o /dev/null -module-name Normal
66
// RUN: echo 'public func flat() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Flat.swiftinterface -emit-module -o /dev/null -module-name Flat
7-
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name FMWK
7+
// RUN: echo 'public func fmwk() {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/System/Library/Frameworks/FMWK.framework/Modules/FMWK.swiftmodule/%target-cpu.swiftinterface -emit-module -o /dev/null -module-name FMWK
88

99
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -v -o %t/prebuilt
1010
// RUN: ls %t/prebuilt | %FileCheck %s
@@ -19,7 +19,7 @@
1919
// This should still be able to use the prebuilt modules because they track
2020
// content hashes, not just size+mtime.
2121
// RUN: rm -rf %t/MCP
22-
// RUN: %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
22+
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-cpu.swiftinterface
2323
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
2424
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
2525
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/*.swiftmodule
@@ -31,7 +31,7 @@
3131
// Actually change a file in the SDK, to check that we're tracking dependencies
3232
// at all.
3333
// RUN: rm -rf %t/MCP
34-
// RUN: echo "public func another()" >> %t/sdk/usr/lib/swift/Normal.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
34+
// RUN: echo "public func another()" >> %t/sdk/usr/lib/swift/Normal.swiftmodule/%target-cpu.swiftinterface
3535
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -Fsystem %t/sdk/System/Library/Frameworks -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
3636
// RUN: ls %t/MCP/*.swiftmodule | %FileCheck -check-prefix CHECK-CACHE %s
3737
// RUN: not %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Normal-*.swiftmodule

test/ParseableInterface/swift_build_sdk_interfaces/track-system-dependencies.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: cp -r %S/Inputs/system-dependencies-sdk %t/sdk
3-
// RUN: echo 'import Platform; public func usesCStruct(_: SomeCStruct?) {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Swifty.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module -o /dev/null -module-name Swifty -sdk %t/sdk
3+
// RUN: echo 'import Platform; public func usesCStruct(_: SomeCStruct?) {}' | %target-swift-frontend - -emit-parseable-module-interface-path %t/sdk/usr/lib/swift/Swifty.swiftmodule/%target-cpu.swiftinterface -emit-module -o /dev/null -module-name Swifty -sdk %t/sdk
44

55
// RUN: %swift_build_sdk_interfaces -sdk %t/sdk -v -o %t/prebuilt
66
// RUN: ls %t/prebuilt | %FileCheck %s
@@ -13,7 +13,7 @@
1313
// This should still be able to use the prebuilt modules because they track
1414
// content hashes, not just size+mtime.
1515
// RUN: rm -rf %t/MCP
16-
// RUN: %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/include/Platform.h
16+
// RUN: %{python} %S/../ModuleCache/Inputs/make-old.py %t/sdk/usr/include/Platform.h
1717
// RUN: %target-typecheck-verify-swift -sdk %t/sdk -I %t/sdk/usr/lib/swift/ -module-cache-path %t/MCP -prebuilt-module-cache-path %t/prebuilt
1818
// RUN: %{python} %S/../ModuleCache/Inputs/check-is-forwarding-module.py %t/MCP/Swifty-*.swiftmodule
1919

test/lit.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,10 +1087,6 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
10871087
config.target_object_format = "elf"
10881088
config.target_shared_library_prefix = 'lib'
10891089
config.target_shared_library_suffix = ".so"
1090-
config.target_swiftmodule_name = get_architecture_value(armv7="arm.swiftmodule",
1091-
aarch64="arm64.swiftmodule")
1092-
config.target_swiftdoc_name = get_architecture_value(armv7="arm.swiftdoc",
1093-
aarch64="arm64.swiftdoc")
10941090
config.target_runtime = "native"
10951091
config.target_swift_autolink_extract = inferSwiftBinary("swift-autolink-extract")
10961092
config.target_sdk_name = "android"

utils/PathSanitizingFileCheck

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@ constants.""")
6767
slashes_re = r'/'
6868

6969
stdin = sys.stdin.read()
70+
71+
if args.enable_windows_compatibility:
72+
# Let's look for paths in the output, and try to transform them to use
73+
# Unix directory separators to be automatically picked up by the tests.
74+
# This only picks up absolute paths, but those should be the more
75+
# common in the tools output and the easier to detect without false
76+
# positives.
77+
78+
def replace_slashes(matchobj):
79+
return re.sub(r'\\\\|\\', r'/', matchobj.group(0))
80+
81+
# The regex is composed of three parts:
82+
# Matches a drive letter followed by a slash (backward
83+
# escaped, simple backward, or forward)
84+
stdin = re.sub(r'\b[a-zA-Z]:(?:\\\\|\\|\/)' +
85+
# Matches the path part, it always ends up in a slash.
86+
r'(?:[-a-zA-Z0-9_.]+(?:\\\\|\\|\/))*' +
87+
# Matches the last path component, which do not has a
88+
# trailing slash, but it is optional.
89+
r'(?:[-a-zA-Z0-9_.]+)?\b',
90+
replace_slashes, stdin)
91+
7092
for s in args.sanitize_strings:
7193
replacement, pattern = s.split('=', 1)
7294
# We are replacing the Unix path separators in the paths passed as

0 commit comments

Comments
 (0)