Compare commits

..
Author SHA1 Message Date
Guillaume Lessard 7c6ad0fc39 Merge pull request #286 from apple/dev/fix-pread-truncation-windows-1.6.0
[Windows] fix pread/pwrite truncation
2026-01-13 13:53:28 -08:00
lee 13851a3421 Fix silent buffer size truncation in Windows pread/pwrite 2026-01-13 13:37:44 -08:00
Guillaume Lessard 8f8d80a4fe Merge pull request #285 from glessard/fix-HRESULT_FACILITY-1.6.0
[Windows] Fix HRESULT_FACILITY
2026-01-13 13:33:25 -08:00
Guillaume Lessard 608a75b962 Merge pull request #284 from glessard/workflow-edits-1.6.0-again
[ci] re-allow 5.9 and 5.10 for 1.6.x
2026-01-13 12:49:27 -08:00
AZero13 0dbbab4aa1 Fix HRESULT_FACILITY
HRESULT_FACILITY is >> 16 & 0x1fff, not <<
2026-01-13 12:41:47 -08:00
Guillaume Lessard 2eb655e0b7 [ci] re-allow 5.9 and 5.10
- they were excluded in error.
2026-01-13 12:38:57 -08:00
Guillaume Lessard 07a3f090d7 Merge pull request #280 from glessard/workflow-edits-1.6.0
[ci] adjust the pull-request action
2026-01-08 17:06:26 -08:00
Guillaume Lessard dda2b535b7 [ci] adjust the pull-request action 2026-01-08 16:46:01 -08:00
Guillaume Lessard 9ddc89964b Merge pull request #263 from apple/workflow-edits-1.6.0
[1.6.0] Apply GitHub workflow edits
2025-09-18 11:14:47 -07:00
Guillaume Lessard 18a52c4729 [workflows] declare 2D exclusions 2025-09-18 10:47:41 -07:00
Guillaume Lessard 1c1ad1d3f4 [workflows] change ubuntus to test against 2025-09-18 10:09:02 -07:00
Guillaume Lessard 395a77f0aa Merge pull request #260 from apple/eng/PR-duplicate-as-release/1.6.0
[1.6] Fix: FileDescriptor.duplicate(as:) returns an invalid file descriptor on Windows
2025-09-15 10:31:53 -07:00
Jake Petroules b1618475cc [1.6] Fix: FileDescriptor.duplicate(as:) returns an invalid file descriptor on Windows
FileDescriptor.duplicate(as:) is backed by dup2 on Unix, and _dup2 on Windows.
On Unix, dup2 returns its second argument. On Windows, _dup2 instead returns
0 on success and -1 on error. This results in the newly returned FileDescriptor
object always containing a '0' file descriptor rather than the newly created
file descriptor, in violation of the documented behavior.

Account for the platform difference in the syscall wrapper to fix this.

Closes #192

(cherry picked from commit b2711a872a)
2025-09-15 10:16:15 -07:00
Guillaume Lessard 890830fff1 Merge pull request #254 from jrflat/fix-generic-int-typedefs-1.6.0 2025-08-03 17:11:41 -07:00
Jonathan Flat a5f13c77b8 Fix typedef errors on platforms with _ASM_GENERIC_INT headers 2025-08-03 11:24:24 -06:00
23 changed files with 138 additions and 115 deletions

No files matched your search

+45 -16
View File
@@ -1,5 +1,8 @@
name: Pull request
permissions:
contents: read
on:
pull_request:
types: [opened, reopened, synchronize]
@@ -9,18 +12,50 @@ jobs:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_os_versions: '["jammy", "focal"]'
enable_macos_checks: true
# FIXME: https://github.com/swiftlang/github-workflows/pull/140
# Xcode 16.0 and 16.1 are not actually available
macos_exclude_xcode_versions: |
[
{"xcode_version": "16.0"},
{"xcode_version": "16.1"},
]
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
enable_linux_checks: true
linux_os_versions: '["noble", "jammy", "focal"]'
linux_exclude_swift_versions: |
[
{"os_version": "noble", "swift_version": "5.9"},
{"os_version": "noble", "swift_version": "5.10"},
{"os_version": "focal", "swift_version": "nightly-6.2"},
{"os_version": "focal", "swift_version": "6.2"},
{"os_version": "focal", "swift_version": "nightly-6.3"},
{"os_version": "focal", "swift_version": "6.3"},
{"os_version": "focal", "swift_version": "nightly-main"},
]
enable_macos_checks: true
macos_exclude_xcode_versions: '[]'
enable_windows_checks: true
windows_exclude_swift_versions: |
[
{"swift_version": "5.9"},
{"swift_version": "5.10"}
]
enable_linux_static_sdk_build: true
linux_static_sdk_exclude_swift_versions: |
[
{"os_version": "focal", "swift_version": "nightly-6.2"},
{"os_version": "focal", "swift_version": "6.2"},
{"os_version": "focal", "swift_version": "nightly-6.3"},
{"os_version": "focal", "swift_version": "6.3"},
{"os_version": "focal", "swift_version": "nightly-main"},
]
enable_wasm_sdk_build: true
wasm_exclude_swift_versions: |
[
{"os_version": "focal", "swift_version": "nightly-6.2"},
{"os_version": "focal", "swift_version": "6.2"},
{"os_version": "focal", "swift_version": "nightly-6.3"},
{"os_version": "focal", "swift_version": "6.3"},
{"os_version": "focal", "swift_version": "nightly-main"},
]
enable_android_sdk_build: true
android_exclude_swift_versions: |
[
{"os_version": "focal", "swift_version": "nightly-main"},
]
build-abi-stable:
name: Build ABI Stable
@@ -31,13 +66,7 @@ jobs:
enable_windows_checks: false
# Only build
macos_build_command: "xcrun swift build --build-tests"
# FIXME: https://github.com/swiftlang/github-workflows/pull/140
# Xcode 16.0 and 16.1 are not actually available
macos_exclude_xcode_versions: |
[
{"xcode_version": "16.0"},
{"xcode_version": "16.1"},
]
macos_exclude_xcode_versions: '[]'
# Enable availability to match ABI stable verion of system.
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI -Xbuild-tools-swiftc -DSYSTEM_ABI_STABLE"
+4 -4
View File
@@ -25,7 +25,7 @@ struct Available {
self.name = "System"
self.version = version
self.osAvailability = osAvailability
self.sourceAvailability = "macOS 14.0, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
self.sourceAvailability = "macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
}
var swiftSetting: SwiftSetting {
@@ -81,7 +81,7 @@ let swiftSettings = swiftSettingsAvailability + swiftSettingsCI + [
"SYSTEM_PACKAGE_DARWIN",
.when(platforms: [.macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .visionOS])),
.define("SYSTEM_PACKAGE"),
// .define("ENABLE_MOCKING", .when(configuration: .debug)),
.define("ENABLE_MOCKING", .when(configuration: .debug)),
.enableExperimentalFeature("Lifetimes"),
]
@@ -97,8 +97,8 @@ let platforms: [SupportedPlatform] = [
.tvOS("26"),
.visionOS("26"),
]
#else
let platforms: [SupportedPlatform] = [.macOS(.v14)]
#else
let platforms: [SupportedPlatform]? = nil
#endif
#if os(Linux)
+2
View File
@@ -134,11 +134,13 @@ typedef struct __SWIFT_IORING_SQE_FALLBACK_STRUCT swift_io_uring_sqe;
#define IORING_FEAT_RW_ATTR (1U << 16)
#define IORING_FEAT_NO_IOWAIT (1U << 17)
#if !defined(_ASM_GENERIC_INT_LL64_H) && !defined(_ASM_GENERIC_INT_L64_H) && !defined(_UAPI_ASM_GENERIC_INT_LL64_H) && !defined(_UAPI_ASM_GENERIC_INT_L64_H)
typedef uint8_t __u8;
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef uint64_t __u64;
typedef int32_t __s32;
#endif
#ifndef __kernel_rwf_t
typedef int __kernel_rwf_t;
+2 -6
View File
@@ -11,7 +11,7 @@
/// occurred.
@frozen
@available(System 0.0.1, *)
public struct Errno: RawRepresentable, Error, Hashable {
public struct Errno: RawRepresentable, Error, Hashable, Codable {
/// The raw C error number.
@_alwaysEmitIntoClient
public let rawValue: CInt
@@ -160,7 +160,7 @@ public struct Errno: RawRepresentable, Error, Hashable {
/// No child processes.
///
/// A `wait(2)` or `waitpid(2)` function was executed
/// by a process that dosn't have any existing child processes
/// by a process that doesn't have any existing child processes
/// or whose child processes are all already being waited for.
///
/// The corresponding C error is `ECHILD`.
@@ -1390,10 +1390,6 @@ public struct Errno: RawRepresentable, Error, Hashable {
public static var EOPNOTSUPP: Errno { notSupportedOnSocket }
}
#if !hasFeature(Embedded)
extension FileDescriptor: Codable {}
#endif
// Constants defined in header but not man page
@available(System 0.0.1, *)
extension Errno {
+4 -16
View File
@@ -15,7 +15,7 @@
/// in the same way as you manage a raw C file handle.
@frozen
@available(System 0.0.1, *)
public struct FileDescriptor: RawRepresentable, Hashable {
public struct FileDescriptor: RawRepresentable, Hashable, Codable {
/// The raw C file handle.
@_alwaysEmitIntoClient
public let rawValue: CInt
@@ -25,10 +25,6 @@ public struct FileDescriptor: RawRepresentable, Hashable {
public init(rawValue: CInt) { self.rawValue = rawValue }
}
#if !hasFeature(Embedded)
extension FileDescriptor: Codable {}
#endif
// Standard file descriptors.
@available(System 0.0.1, *)
extension FileDescriptor {
@@ -50,7 +46,7 @@ extension FileDescriptor {
/// The desired read and write access for a newly opened file.
@frozen
@available(System 0.0.1, *)
public struct AccessMode: RawRepresentable, Sendable, Hashable {
public struct AccessMode: RawRepresentable, Sendable, Hashable, Codable {
/// The raw C access mode.
@_alwaysEmitIntoClient
public var rawValue: CInt
@@ -93,7 +89,7 @@ extension FileDescriptor {
/// Options that specify behavior for a newly-opened file.
@frozen
@available(System 0.0.1, *)
public struct OpenOptions: OptionSet, Sendable, Hashable {
public struct OpenOptions: OptionSet, Sendable, Hashable, Codable {
/// The raw C options.
@_alwaysEmitIntoClient
public var rawValue: CInt
@@ -331,7 +327,7 @@ extension FileDescriptor {
/// Options for specifying what a file descriptor's offset is relative to.
@frozen
@available(System 0.0.1, *)
public struct SeekOrigin: RawRepresentable, Sendable, Hashable {
public struct SeekOrigin: RawRepresentable, Sendable, Hashable, Codable {
/// The raw C value.
@_alwaysEmitIntoClient
public var rawValue: CInt
@@ -406,14 +402,6 @@ extension FileDescriptor {
}
}
#if !hasFeature(Embedded)
extension FileDescriptor.AccessMode: Codable { }
extension FileDescriptor.OpenOptions: Codable { }
extension FileDescriptor.SeekOrigin: Codable { }
#endif
@available(System 0.0.1, *)
extension FileDescriptor.AccessMode
: CustomStringConvertible, CustomDebugStringConvertible
-2
View File
@@ -68,7 +68,6 @@ extension FilePath {
@available(System 0.0.1, *)
extension FilePath: Hashable {}
#if !hasFeature(Embedded)
@available(System 0.0.1, *)
extension FilePath: Codable {
// Encoder is synthesized; it probably should have been explicit and used
@@ -89,4 +88,3 @@ extension FilePath: Codable {
}
}
}
#endif
@@ -128,15 +128,9 @@ extension SystemString {
}
}
#if hasFeature(Embedded)
protocol _StrSliceCodable {}
#else
protocol _StrSliceCodable: Codable {}
#endif
// Unifying protocol for common functionality between roots, components,
// and views onto SystemString and FilePath.
internal protocol _StrSlice: _PlatformStringable, Hashable, _StrSliceCodable {
internal protocol _StrSlice: _PlatformStringable, Hashable, Codable {
var _storage: SystemString { get }
var _range: Range<SystemString.Index> { get }
@@ -144,7 +138,6 @@ internal protocol _StrSlice: _PlatformStringable, Hashable, _StrSliceCodable {
func _invariantCheck()
}
extension _StrSlice {
internal var _slice: Slice<SystemString> {
Slice(base: _storage, bounds: _range)
@@ -517,7 +517,7 @@ fileprivate func HRESULT_CODE(_ hr: HRESULT) -> DWORD {
@inline(__always)
fileprivate func HRESULT_FACILITY(_ hr: HRESULT) -> DWORD {
DWORD(hr << 16) & 0x1fff
DWORD(hr >> 16) & 0x1fff
}
@inline(__always)
+1 -5
View File
@@ -18,7 +18,7 @@
/// perms == [.ownerReadWrite, .groupRead, .otherRead] // true
@frozen
@available(System 0.0.1, *)
public struct FilePermissions: OptionSet, Sendable, Hashable {
public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
/// The raw C file permissions.
@_alwaysEmitIntoClient
public let rawValue: CModeT
@@ -132,10 +132,6 @@ public struct FilePermissions: OptionSet, Sendable, Hashable {
public static var saveText: FilePermissions { .init(rawValue: 0o1000) }
}
#if !hasFeature(Embedded)
extension FilePermissions: Codable { }
#endif
@available(System 0.0.1, *)
extension FilePermissions
: CustomStringConvertible, CustomDebugStringConvertible
+1 -5
View File
@@ -13,7 +13,7 @@ public extension IORing {
}
public extension IORing.Completion {
struct Flags: OptionSet, Hashable {
struct Flags: OptionSet, Hashable, Codable {
public let rawValue: UInt32
@inlinable public init(rawValue: UInt32) {
@@ -32,10 +32,6 @@ public extension IORing.Completion {
}
}
#if !hasFeature(Embedded)
extension IORing.Completion.Flags: Codable {}
#endif
public extension IORing.Completion {
@inlinable var context: UInt64 {
get {
+1 -1
View File
@@ -320,7 +320,7 @@ extension IORing.Request {
* ASYNC_CANCEL flags.
*
* IORING_ASYNC_CANCEL_ALL Cancel all requests that match the given key
* IORING_ASYNC_CANCEL_FD Key off 'fd' for cancellation rather than the
* IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the
* request 'user_data'
* IORING_ASYNC_CANCEL_ANY Match any request
* IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor
+3 -13
View File
@@ -45,7 +45,7 @@ extension RawIORequest {
case unlinkAt = 36
}
public struct Flags: OptionSet, Hashable {
public struct Flags: OptionSet, Hashable, Codable {
public let rawValue: UInt8
@inlinable public init(rawValue: UInt8) {
@@ -135,7 +135,7 @@ extension RawIORequest {
// splice_flags
}
public struct ReadWriteFlags: OptionSet, Hashable {
public struct ReadWriteFlags: OptionSet, Hashable, Codable {
public var rawValue: UInt32
@inlinable public init(rawValue: UInt32) {
self.rawValue = rawValue
@@ -156,7 +156,7 @@ extension RawIORequest {
@inlinable public static var append: RawIORequest.ReadWriteFlags { ReadWriteFlags(rawValue: 1 << 4) }
}
public struct TimeOutFlags: OptionSet, Hashable {
public struct TimeOutFlags: OptionSet, Hashable, Codable {
public var rawValue: UInt32
@inlinable public init(rawValue: UInt32) {
@@ -168,16 +168,6 @@ extension RawIORequest {
}
}
#if !hasFeature(Embedded)
extension IORing.Completion.Flags: Codable {}
extension RawIORequest.Flags: Codable {}
extension RawIORequest.ReadWriteFlags: Codable {}
extension RawIORequest.TimeOutFlags: Codable {}
#endif
extension RawIORequest {
@inlinable
static func nop() -> RawIORequest {
-7
View File
@@ -37,17 +37,10 @@ internal typealias _COffT = off_t
// MARK: syscalls and variables
#if SYSTEM_PACKAGE_DARWIN
#if hasFeature(Embedded)
internal var system_errno: CInt {
get { _DarwinFoundation1.errno }
set { _DarwinFoundation1.errno = newValue }
}
#else
internal var system_errno: CInt {
get { Darwin.errno }
set { Darwin.errno = newValue }
}
#endif
#elseif os(Windows)
internal var system_errno: CInt {
get {
@@ -135,7 +135,11 @@ internal func dup(_ fd: Int32) -> Int32 {
@inline(__always)
internal func dup2(_ fd: Int32, _ fd2: Int32) -> Int32 {
_dup2(fd, fd2)
// _dup2 returns 0 to indicate success.
if _dup2(fd, fd2) == 0 {
return fd2
}
return -1
}
@inline(__always)
@@ -145,6 +149,12 @@ internal func pread(
let handle: intptr_t = _get_osfhandle(fd)
if handle == /* INVALID_HANDLE_VALUE */ -1 { ucrt._set_errno(EBADF); return -1 }
// Windows ReadFile accepts DWORD (32-bit) for buffer size, so validate nbyte doesn't exceed it
if nbyte > Int(DWORD.max) {
ucrt._set_errno(EINVAL)
return -1
}
// NOTE: this is a non-owning handle, do *not* call CloseHandle on it
let hFile: HANDLE = HANDLE(bitPattern: handle)!
@@ -167,6 +177,12 @@ internal func pwrite(
let handle: intptr_t = _get_osfhandle(fd)
if handle == /* INVALID_HANDLE_VALUE */ -1 { ucrt._set_errno(EBADF); return -1 }
// Windows WriteFile accepts DWORD (32-bit) for buffer size, so validate nbyte doesn't exceed it
if nbyte > Int(DWORD.max) {
ucrt._set_errno(EINVAL)
return -1
}
// NOTE: this is a non-owning handle, do *not* call CloseHandle on it
let hFile: HANDLE = HANDLE(bitPattern: handle)!
+4 -11
View File
@@ -8,7 +8,8 @@
*/
// A platform-native character representation, currently used for file paths
internal struct SystemChar: RawRepresentable, Sendable, Comparable, Hashable {
internal struct SystemChar:
RawRepresentable, Sendable, Comparable, Hashable, Codable {
internal typealias RawValue = CInterop.PlatformChar
internal var rawValue: RawValue
@@ -22,10 +23,6 @@ internal struct SystemChar: RawRepresentable, Sendable, Comparable, Hashable {
}
}
#if !hasFeature(Embedded)
extension SystemChar: Codable {}
#endif
extension SystemChar {
internal init(ascii: Unicode.Scalar) {
self.init(rawValue: numericCast(UInt8(ascii: ascii)))
@@ -140,7 +137,6 @@ extension SystemString: RandomAccessCollection, MutableCollection {
}
}
}
extension SystemString: RangeReplaceableCollection {
internal mutating func replaceSubrange<C: Collection>(
_ subrange: Range<Index>, with newElements: C
@@ -177,10 +173,7 @@ extension SystemString: RangeReplaceableCollection {
}
}
extension SystemString: Hashable {}
#if !hasFeature(Embedded)
extension SystemString: Codable {
extension SystemString: Hashable, Codable {
// Encoder is synthesized; it probably should have been explicit and used
// a single-value container, but making that change now is somewhat risky.
@@ -201,9 +194,9 @@ extension SystemString: Codable {
}
}
}
#endif
extension SystemString {
internal func withNullTerminatedSystemChars<T>(
_ f: (UnsafeBufferPointer<SystemChar>) throws -> T
) rethrows -> T {
+1 -1
View File
@@ -52,7 +52,7 @@ internal func _debugPrecondition(
// Only check in debug mode.
if _slowPath(_isDebugAssertConfiguration()) {
precondition(
condition(), "\(message)", file: file, line: line)
condition(), String(describing: message), file: file, line: line)
}
}
+2 -2
View File
@@ -52,13 +52,13 @@ extension Slice where Element: Equatable {
return self[...idx]
}
// If `e` is present, eat up to first occurrence of `e`
// If `e` is present, eat up to first occurence of `e`
internal mutating func _eatUntil(_ e: Element) -> Slice? {
guard let idx = self.firstIndex(of: e) else { return nil }
return _eatUntil(idx)
}
// If `e` is present, eat up to and through first occurrence of `e`
// If `e` is present, eat up to and through first occurence of `e`
internal mutating func _eatThrough(_ e: Element) -> Slice? {
guard let idx = self.firstIndex(of: e) else { return nil }
return _eatThrough(idx)
+2 -4
View File
@@ -22,7 +22,7 @@ import CSystem
@available(System 0.0.1, *)
final class FileOperationsTest: XCTestCase {
#if ENABLE_MOCKING && !os(WASI) // Would need to use _getConst funcs from CSystem
#if !os(WASI) // Would need to use _getConst funcs from CSystem
func testSyscalls() {
let fd = FileDescriptor(rawValue: 1)
@@ -91,7 +91,7 @@ final class FileOperationsTest: XCTestCase {
for test in syscallTestCases { test.runAllTests() }
}
#endif // ENABLE_MOCKING && !os(WASI)
#endif // !os(WASI)
func testWriteFromEmptyBuffer() throws {
#if os(Windows)
@@ -215,7 +215,6 @@ final class FileOperationsTest: XCTestCase {
}
}
#if ENABLE_MOCKING
func testGithubIssues() {
// https://github.com/apple/swift-system/issues/26
#if os(WASI)
@@ -234,7 +233,6 @@ final class FileOperationsTest: XCTestCase {
}
issue26.runAllTests()
}
#endif // ENABLE_MOCKING
func testResizeFile() throws {
try withTemporaryFilePath(basename: "testResizeFile") { path in
@@ -242,6 +242,53 @@ final class FileOperationsTestWindows: XCTestCase {
}
}
}
/// Test that buffer sizes exceeding DWORD.max (4GB) are properly rejected
func testBufferSizeLimit() throws {
try withTemporaryFilePath(basename: "testBufferSizeLimit") { path in
let fd = try FileDescriptor.open(
path.appending("test.txt"),
.readWrite,
options: [.create, .truncate],
permissions: .ownerReadWrite
)
defer { try? fd.close() }
// Write some data first
try fd.writeAll("test data".utf8)
// Allocate a small buffer for testing
let buffer = UnsafeMutableRawBufferPointer.allocate(byteCount: 1024, alignment: 1)
defer { buffer.deallocate() }
// Test that a count exceeding DWORD.max (UInt32.max = 4,294,967,295) returns EINVAL
// We use a buffer pointer but pass a count > DWORD.max
let oversizedCount = Int(DWORD.max) + 1
let oversizedBuffer = UnsafeMutableRawBufferPointer(
start: buffer.baseAddress,
count: oversizedCount
)
// pread should fail with EINVAL
do {
_ = try fd.read(fromAbsoluteOffset: 0, into: oversizedBuffer)
XCTFail("Expected EINVAL for buffer size exceeding DWORD.max")
} catch let err as Errno {
XCTAssertEqual(err, .invalidArgument, "Expected EINVAL, got \(err)")
}
// pwrite should also fail with EINVAL
do {
_ = try fd.write(toAbsoluteOffset: 0, UnsafeRawBufferPointer(oversizedBuffer))
XCTFail("Expected EINVAL for buffer size exceeding DWORD.max")
} catch let err as Errno {
XCTAssertEqual(err, .invalidArgument, "Expected EINVAL, got \(err)")
}
// Verify that exactly DWORD.max works (if we had a buffer that large)
// We can't easily test this without allocating 4GB, but the boundary is correct
}
}
}
#endif // os(Windows)
@@ -7,7 +7,6 @@
See https://swift.org/LICENSE.txt for license information
*/
#if ENABLE_MOCKING
import XCTest
#if SYSTEM_PACKAGE
@@ -106,4 +105,3 @@ final class FilePathParsingTest: XCTestCase {
}
}
}
#endif // ENABLE_MOCKING
@@ -7,7 +7,6 @@
See https://swift.org/LICENSE.txt for license information
*/
#if ENABLE_MOCKING
import XCTest
#if SYSTEM_PACKAGE
@@ -1239,4 +1238,3 @@ final class FilePathSyntaxTest: XCTestCase {
}
}
#endif // ENABLE_MOCKING
-2
View File
@@ -7,7 +7,6 @@
See https://swift.org/LICENSE.txt for license information
*/
#if ENABLE_MOCKING
import XCTest
#if SYSTEM_PACKAGE
@@ -49,4 +48,3 @@ final class MockingTest: XCTestCase {
XCTAssertFalse(mockingEnabled)
}
}
#endif // ENABLE_MOCKING
@@ -17,7 +17,6 @@ import XCTest
internal struct Wildcard: Hashable {}
#if ENABLE_MOCKING
extension Trace.Entry {
/// This implements `==` with wildcard matching.
/// (`Entry` cannot conform to `Equatable`/`Hashable` this way because
@@ -34,7 +33,6 @@ extension Trace.Entry {
return true
}
}
#endif // ENABLE_MOCKING
// To aid debugging, force failures to fatal error
internal var forceFatalFailures = false
@@ -83,7 +81,6 @@ extension TestCase {
fail(message)
}
}
#if ENABLE_MOCKING
func expectMatch(
_ expected: Trace.Entry?, _ actual: Trace.Entry?,
_ message: String? = nil
@@ -105,7 +102,6 @@ extension TestCase {
fail(message)
}
}
#endif // ENABLE_MOCKING
func expectNil<T>(
_ actual: T?,
_ message: String? = nil
@@ -146,7 +142,6 @@ extension TestCase {
}
#if ENABLE_MOCKING
internal struct MockTestCase: TestCase {
var file: StaticString
var line: UInt
@@ -246,7 +241,6 @@ internal struct MockTestCase: TestCase {
}
}
}
#endif // ENABLE_MOCKING
internal func withWindowsPaths(enabled: Bool, _ body: () -> ()) {
_withWindowsPaths(enabled: enabled, body)