Merge pull request #21902 from compnerd/interpreter-tests

test: port most of the interpreter tests to Windows
diff --git a/test/Interpreter/SDK/libc.swift b/test/Interpreter/SDK/libc.swift
index 0e1dd7d..e052e5a 100644
--- a/test/Interpreter/SDK/libc.swift
+++ b/test/Interpreter/SDK/libc.swift
@@ -13,6 +13,8 @@
   import Darwin
 #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
   import Glibc
+#elseif os(Windows)
+  import MSVCRT
 #endif
 
 let sourcePath = CommandLine.arguments[1]
diff --git a/test/Interpreter/dynamic_replacement.swift b/test/Interpreter/dynamic_replacement.swift
index c358aa9..58f26c5 100644
--- a/test/Interpreter/dynamic_replacement.swift
+++ b/test/Interpreter/dynamic_replacement.swift
@@ -55,10 +55,11 @@
 
 #if os(Linux)
   import Glibc
-  let dylibSuffix = "so"
+#elseif os(Windows)
+  import MSVCRT
+  import WinSDK
 #else
   import Darwin
-  let dylibSuffix = "dylib"
 #endif
 
 var DynamicallyReplaceable = TestSuite("DynamicallyReplaceable")
@@ -108,6 +109,16 @@
             expectedResult(useOrig, "public_enum_generic_func"))
 }
 
+private func target_library_name(_ name: String) -> String {
+#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
+  return "lib\(name).dylib"
+#elseif os(Windows)
+  return "\(name).dll"
+#else
+  return "lib\(name).so"
+#endif
+}
+
 DynamicallyReplaceable.test("DynamicallyReplaceable") {
   var executablePath = CommandLine.arguments[0]
   executablePath.removeLast(4)
@@ -118,9 +129,11 @@
   // Now, test with the module containing the replacements.
 
 #if os(Linux)
-	_ = dlopen("libModule2."+dylibSuffix, RTLD_NOW)
+	_ = dlopen(target_library_name("Module2"), RTLD_NOW)
+#elseif os(Windows)
+        _ = LoadLibraryA(target_library_name("Module2"))
 #else
-	_ = dlopen(executablePath+"libModule2."+dylibSuffix, RTLD_NOW)
+	_ = dlopen(target_library_name("Module2"), RTLD_NOW)
 #endif
 	checkExpectedResults(forOriginalLibrary: false)
 }
diff --git a/test/Interpreter/dynamic_replacement_chaining.swift b/test/Interpreter/dynamic_replacement_chaining.swift
index 2b30230..027fe41 100644
--- a/test/Interpreter/dynamic_replacement_chaining.swift
+++ b/test/Interpreter/dynamic_replacement_chaining.swift
@@ -24,25 +24,38 @@
 
 #if os(Linux)
   import Glibc
-  let dylibSuffix = "so"
+#elseif os(Windows)
+  import MSVCRT
+  import WinSDK
 #else
   import Darwin
-  let dylibSuffix = "dylib"
 #endif
 
 var DynamicallyReplaceable = TestSuite("DynamicallyReplaceableChaining")
 
+func target_library_name(_ name: String) -> String {
+#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
+  return "lib\(name).dylib"
+#elseif os(Windows)
+  return "\(name).dll"
+#else
+  return "lib\(name).so"
+#endif
+}
 
 DynamicallyReplaceable.test("DynamicallyReplaceable") {
   var executablePath = CommandLine.arguments[0]
   executablePath.removeLast(4)
 
 #if os(Linux)
-	_ = dlopen("libB."+dylibSuffix, RTLD_NOW)
-	_ = dlopen("libC."+dylibSuffix, RTLD_NOW)
+	_ = dlopen(target_library_name("B"), RTLD_NOW)
+	_ = dlopen(target_library_name("C"), RTLD_NOW)
+#elseif os(Windows)
+        _ = LoadLibraryA(target_library_name("B"))
+        _ = LoadLibraryA(target_library_name("C"))
 #else
-	_ = dlopen(executablePath+"libB."+dylibSuffix, RTLD_NOW)
-	_ = dlopen(executablePath+"libC."+dylibSuffix, RTLD_NOW)
+	_ = dlopen(executablePath+target_library_name("B"), RTLD_NOW)
+	_ = dlopen(executablePath+target_library_name("C"), RTLD_NOW)
 #endif
 
 #if CHAINING
diff --git a/test/Interpreter/extended_grapheme_cluster_literal.swift b/test/Interpreter/extended_grapheme_cluster_literal.swift
index 3577596..a4fc2c8 100644
--- a/test/Interpreter/extended_grapheme_cluster_literal.swift
+++ b/test/Interpreter/extended_grapheme_cluster_literal.swift
@@ -17,7 +17,7 @@
   }
 }
 
-private func string(_ characters: UInt32...) -> String {
+public func string(_ characters: UInt32...) -> String {
   return String(characters.map { Character(UnicodeScalar($0)!) })
 }
 private func expressible<T>(_ literal: Expressible<T>, as type: T.Type)
diff --git a/test/Interpreter/unions-and-bitfields.swift b/test/Interpreter/unions-and-bitfields.swift
index b4830fc..e553650 100644
--- a/test/Interpreter/unions-and-bitfields.swift
+++ b/test/Interpreter/unions-and-bitfields.swift
@@ -1,7 +1,9 @@
-// RUN: %target-build-swift %s -import-objc-header %S/Inputs/unions-and-bitfields.h -disable-bridging-pch -o %t
+// 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
 // RUN: %target-codesign %t
 // RUN: %target-run %t
+
 // REQUIRES: executable_test
+// REQUIRES: objc_interop
 
 // The -disable-bridging-pch above isn't actually relevant to the test; however,
 // precompiled headers don't play nice with the way we include the platform