Skip to content

Commit 1d2290c

Browse files
authored
Merge pull request #21902 from compnerd/interpreter-tests
test: port most of the interpreter tests to Windows
2 parents 8721d98 + d2aad41 commit 1d2290c

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

test/Interpreter/SDK/libc.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import Darwin
1414
#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
1515
import Glibc
16+
#elseif os(Windows)
17+
import MSVCRT
1618
#endif
1719

1820
let sourcePath = CommandLine.arguments[1]

test/Interpreter/dynamic_replacement.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ import StdlibUnittest
5555

5656
#if os(Linux)
5757
import Glibc
58-
let dylibSuffix = "so"
58+
#elseif os(Windows)
59+
import MSVCRT
60+
import WinSDK
5961
#else
6062
import Darwin
61-
let dylibSuffix = "dylib"
6263
#endif
6364

6465
var DynamicallyReplaceable = TestSuite("DynamicallyReplaceable")
@@ -108,6 +109,16 @@ func checkExpectedResults(forOriginalLibrary useOrig: Bool) {
108109
expectedResult(useOrig, "public_enum_generic_func"))
109110
}
110111

112+
private func target_library_name(_ name: String) -> String {
113+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
114+
return "lib\(name).dylib"
115+
#elseif os(Windows)
116+
return "\(name).dll"
117+
#else
118+
return "lib\(name).so"
119+
#endif
120+
}
121+
111122
DynamicallyReplaceable.test("DynamicallyReplaceable") {
112123
var executablePath = CommandLine.arguments[0]
113124
executablePath.removeLast(4)
@@ -118,9 +129,11 @@ DynamicallyReplaceable.test("DynamicallyReplaceable") {
118129
// Now, test with the module containing the replacements.
119130

120131
#if os(Linux)
121-
_ = dlopen("libModule2."+dylibSuffix, RTLD_NOW)
132+
_ = dlopen(target_library_name("Module2"), RTLD_NOW)
133+
#elseif os(Windows)
134+
_ = LoadLibraryA(target_library_name("Module2"))
122135
#else
123-
_ = dlopen(executablePath+"libModule2."+dylibSuffix, RTLD_NOW)
136+
_ = dlopen(target_library_name("Module2"), RTLD_NOW)
124137
#endif
125138
checkExpectedResults(forOriginalLibrary: false)
126139
}

test/Interpreter/dynamic_replacement_chaining.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,38 @@ import StdlibUnittest
2424

2525
#if os(Linux)
2626
import Glibc
27-
let dylibSuffix = "so"
27+
#elseif os(Windows)
28+
import MSVCRT
29+
import WinSDK
2830
#else
2931
import Darwin
30-
let dylibSuffix = "dylib"
3132
#endif
3233

3334
var DynamicallyReplaceable = TestSuite("DynamicallyReplaceableChaining")
3435

36+
func target_library_name(_ name: String) -> String {
37+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
38+
return "lib\(name).dylib"
39+
#elseif os(Windows)
40+
return "\(name).dll"
41+
#else
42+
return "lib\(name).so"
43+
#endif
44+
}
3545

3646
DynamicallyReplaceable.test("DynamicallyReplaceable") {
3747
var executablePath = CommandLine.arguments[0]
3848
executablePath.removeLast(4)
3949

4050
#if os(Linux)
41-
_ = dlopen("libB."+dylibSuffix, RTLD_NOW)
42-
_ = dlopen("libC."+dylibSuffix, RTLD_NOW)
51+
_ = dlopen(target_library_name("B"), RTLD_NOW)
52+
_ = dlopen(target_library_name("C"), RTLD_NOW)
53+
#elseif os(Windows)
54+
_ = LoadLibraryA(target_library_name("B"))
55+
_ = LoadLibraryA(target_library_name("C"))
4356
#else
44-
_ = dlopen(executablePath+"libB."+dylibSuffix, RTLD_NOW)
45-
_ = dlopen(executablePath+"libC."+dylibSuffix, RTLD_NOW)
57+
_ = dlopen(executablePath+target_library_name("B"), RTLD_NOW)
58+
_ = dlopen(executablePath+target_library_name("C"), RTLD_NOW)
4659
#endif
4760

4861
#if CHAINING

test/Interpreter/extended_grapheme_cluster_literal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private struct Expressible
1717
}
1818
}
1919

20-
private func string(_ characters: UInt32...) -> String {
20+
public func string(_ characters: UInt32...) -> String {
2121
return String(characters.map { Character(UnicodeScalar($0)!) })
2222
}
2323
private func expressible<T>(_ literal: Expressible<T>, as type: T.Type)

test/Interpreter/unions-and-bitfields.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// RUN: %target-build-swift %s -import-objc-header %S/Inputs/unions-and-bitfields.h -disable-bridging-pch -o %t
1+
// RUN: %target-build-swift %s -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -import-objc-header %S/Inputs/unions-and-bitfields.h -disable-bridging-pch -o %t
22
// RUN: %target-codesign %t
33
// RUN: %target-run %t
4+
45
// REQUIRES: executable_test
6+
// REQUIRES: objc_interop
57

68
// The -disable-bridging-pch above isn't actually relevant to the test; however,
79
// precompiled headers don't play nice with the way we include the platform

0 commit comments

Comments
 (0)