Compare commits

...
Author SHA1 Message Date
Rauhul Varma 2a309bbd8a fix static string error 2025-08-18 21:00:18 -07:00
Rauhul Varma ecde55d15e WIP enable embedded swift 2025-08-18 20:58:45 -07:00
Guillaume Lessard b6a7776360 Merge pull request #255 from lamtrinhdev/Fix_typo_issues
Fix spelling errors in some comments.
2025-08-12 15:00:43 -07:00
LamTrinh.Dev 0ea6743c17 Fix spelling errors in some comments. 2025-08-11 00:56:26 +07:00
Jonathan Flat 086219bf62 Merge pull request #253 from jrflat/static-and-wasm-sdk-builds
[CI] Enable Linux static SDK and Wasm SDK builds
2025-08-01 16:21:21 -06:00
Jonathan Flat 11d9d4a78e [CI] Enable Linux static SDK and Wasm SDK builds 2025-08-01 14:51:27 -06:00
Jonathan Flat 0c11feadd4 Merge pull request #252 from jrflat/release-mode-testing
Support testing in release mode
2025-07-31 10:11:32 -06:00
Guillaume Lessard 2410aed341 Merge pull request #251 from apple/release/1.6.0
Merge 1.6.x into main
2025-07-31 09:05:02 -07:00
Jonathan Flat 9ec41a667c Support testing in release mode 2025-07-30 18:47:26 -06:00
19 changed files with 98 additions and 25 deletions

No files matched your search

+2
View File
@@ -19,6 +19,8 @@ jobs:
{"xcode_version": "16.1"},
]
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
enable_linux_static_sdk_build: true
enable_wasm_sdk_build: true
build-abi-stable:
name: Build ABI Stable
+4 -4
View File
@@ -25,7 +25,7 @@ struct Available {
self.name = "System"
self.version = version
self.osAvailability = osAvailability
self.sourceAvailability = "macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
self.sourceAvailability = "macOS 14.0, 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]? = nil
#else
let platforms: [SupportedPlatform] = [.macOS(.v14)]
#endif
#if os(Linux)
+5 -1
View File
@@ -11,7 +11,7 @@
/// occurred.
@frozen
@available(System 0.0.1, *)
public struct Errno: RawRepresentable, Error, Hashable, Codable {
public struct Errno: RawRepresentable, Error, Hashable {
/// The raw C error number.
@_alwaysEmitIntoClient
public let rawValue: CInt
@@ -1390,6 +1390,10 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
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 {
+16 -4
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, Codable {
public struct FileDescriptor: RawRepresentable, Hashable {
/// The raw C file handle.
@_alwaysEmitIntoClient
public let rawValue: CInt
@@ -25,6 +25,10 @@ public struct FileDescriptor: RawRepresentable, Hashable, Codable {
public init(rawValue: CInt) { self.rawValue = rawValue }
}
#if !hasFeature(Embedded)
extension FileDescriptor: Codable {}
#endif
// Standard file descriptors.
@available(System 0.0.1, *)
extension FileDescriptor {
@@ -46,7 +50,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, Codable {
public struct AccessMode: RawRepresentable, Sendable, Hashable {
/// The raw C access mode.
@_alwaysEmitIntoClient
public var rawValue: CInt
@@ -89,7 +93,7 @@ extension FileDescriptor {
/// Options that specify behavior for a newly-opened file.
@frozen
@available(System 0.0.1, *)
public struct OpenOptions: OptionSet, Sendable, Hashable, Codable {
public struct OpenOptions: OptionSet, Sendable, Hashable {
/// The raw C options.
@_alwaysEmitIntoClient
public var rawValue: CInt
@@ -327,7 +331,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, Codable {
public struct SeekOrigin: RawRepresentable, Sendable, Hashable {
/// The raw C value.
@_alwaysEmitIntoClient
public var rawValue: CInt
@@ -402,6 +406,14 @@ 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,6 +68,7 @@ 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
@@ -88,3 +89,4 @@ extension FilePath: Codable {
}
}
}
#endif
@@ -128,9 +128,15 @@ 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, Codable {
internal protocol _StrSlice: _PlatformStringable, Hashable, _StrSliceCodable {
var _storage: SystemString { get }
var _range: Range<SystemString.Index> { get }
@@ -138,6 +144,7 @@ internal protocol _StrSlice: _PlatformStringable, Hashable, Codable {
func _invariantCheck()
}
extension _StrSlice {
internal var _slice: Slice<SystemString> {
Slice(base: _storage, bounds: _range)
+5 -1
View File
@@ -18,7 +18,7 @@
/// perms == [.ownerReadWrite, .groupRead, .otherRead] // true
@frozen
@available(System 0.0.1, *)
public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
public struct FilePermissions: OptionSet, Sendable, Hashable {
/// The raw C file permissions.
@_alwaysEmitIntoClient
public let rawValue: CModeT
@@ -132,6 +132,10 @@ public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
public static var saveText: FilePermissions { .init(rawValue: 0o1000) }
}
#if !hasFeature(Embedded)
extension FilePermissions: Codable { }
#endif
@available(System 0.0.1, *)
extension FilePermissions
: CustomStringConvertible, CustomDebugStringConvertible
+5 -1
View File
@@ -13,7 +13,7 @@ public extension IORing {
}
public extension IORing.Completion {
struct Flags: OptionSet, Hashable, Codable {
struct Flags: OptionSet, Hashable {
public let rawValue: UInt32
@inlinable public init(rawValue: UInt32) {
@@ -32,6 +32,10 @@ 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 cancelation rather than the
* IORING_ASYNC_CANCEL_FD Key off 'fd' for cancellation 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
+13 -3
View File
@@ -45,7 +45,7 @@ extension RawIORequest {
case unlinkAt = 36
}
public struct Flags: OptionSet, Hashable, Codable {
public struct Flags: OptionSet, Hashable {
public let rawValue: UInt8
@inlinable public init(rawValue: UInt8) {
@@ -135,7 +135,7 @@ extension RawIORequest {
// splice_flags
}
public struct ReadWriteFlags: OptionSet, Hashable, Codable {
public struct ReadWriteFlags: OptionSet, Hashable {
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, Codable {
public struct TimeOutFlags: OptionSet, Hashable {
public var rawValue: UInt32
@inlinable public init(rawValue: UInt32) {
@@ -168,6 +168,16 @@ 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,10 +37,17 @@ 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 {
+11 -4
View File
@@ -8,8 +8,7 @@
*/
// A platform-native character representation, currently used for file paths
internal struct SystemChar:
RawRepresentable, Sendable, Comparable, Hashable, Codable {
internal struct SystemChar: RawRepresentable, Sendable, Comparable, Hashable {
internal typealias RawValue = CInterop.PlatformChar
internal var rawValue: RawValue
@@ -23,6 +22,10 @@ internal struct SystemChar:
}
}
#if !hasFeature(Embedded)
extension SystemChar: Codable {}
#endif
extension SystemChar {
internal init(ascii: Unicode.Scalar) {
self.init(rawValue: numericCast(UInt8(ascii: ascii)))
@@ -137,6 +140,7 @@ extension SystemString: RandomAccessCollection, MutableCollection {
}
}
}
extension SystemString: RangeReplaceableCollection {
internal mutating func replaceSubrange<C: Collection>(
_ subrange: Range<Index>, with newElements: C
@@ -173,7 +177,10 @@ extension SystemString: RangeReplaceableCollection {
}
}
extension SystemString: Hashable, Codable {
extension SystemString: Hashable {}
#if !hasFeature(Embedded)
extension SystemString: Codable {
// Encoder is synthesized; it probably should have been explicit and used
// a single-value container, but making that change now is somewhat risky.
@@ -194,9 +201,9 @@ extension SystemString: Hashable, 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(), String(describing: message), file: file, line: line)
condition(), "\(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 occurence of `e`
// If `e` is present, eat up to first occurrence 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 occurence of `e`
// If `e` is present, eat up to and through first occurrence of `e`
internal mutating func _eatThrough(_ e: Element) -> Slice? {
guard let idx = self.firstIndex(of: e) else { return nil }
return _eatThrough(idx)
+4 -2
View File
@@ -22,7 +22,7 @@ import CSystem
@available(System 0.0.1, *)
final class FileOperationsTest: XCTestCase {
#if !os(WASI) // Would need to use _getConst funcs from CSystem
#if ENABLE_MOCKING && !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 // !os(WASI)
#endif // ENABLE_MOCKING && !os(WASI)
func testWriteFromEmptyBuffer() throws {
#if os(Windows)
@@ -215,6 +215,7 @@ final class FileOperationsTest: XCTestCase {
}
}
#if ENABLE_MOCKING
func testGithubIssues() {
// https://github.com/apple/swift-system/issues/26
#if os(WASI)
@@ -233,6 +234,7 @@ final class FileOperationsTest: XCTestCase {
}
issue26.runAllTests()
}
#endif // ENABLE_MOCKING
func testResizeFile() throws {
try withTemporaryFilePath(basename: "testResizeFile") { path in
@@ -7,6 +7,7 @@
See https://swift.org/LICENSE.txt for license information
*/
#if ENABLE_MOCKING
import XCTest
#if SYSTEM_PACKAGE
@@ -105,3 +106,4 @@ final class FilePathParsingTest: XCTestCase {
}
}
}
#endif // ENABLE_MOCKING
@@ -7,6 +7,7 @@
See https://swift.org/LICENSE.txt for license information
*/
#if ENABLE_MOCKING
import XCTest
#if SYSTEM_PACKAGE
@@ -1238,3 +1239,4 @@ final class FilePathSyntaxTest: XCTestCase {
}
}
#endif // ENABLE_MOCKING
+2
View File
@@ -7,6 +7,7 @@
See https://swift.org/LICENSE.txt for license information
*/
#if ENABLE_MOCKING
import XCTest
#if SYSTEM_PACKAGE
@@ -48,3 +49,4 @@ final class MockingTest: XCTestCase {
XCTAssertFalse(mockingEnabled)
}
}
#endif // ENABLE_MOCKING
@@ -17,6 +17,7 @@ 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
@@ -33,6 +34,7 @@ extension Trace.Entry {
return true
}
}
#endif // ENABLE_MOCKING
// To aid debugging, force failures to fatal error
internal var forceFatalFailures = false
@@ -81,6 +83,7 @@ extension TestCase {
fail(message)
}
}
#if ENABLE_MOCKING
func expectMatch(
_ expected: Trace.Entry?, _ actual: Trace.Entry?,
_ message: String? = nil
@@ -102,6 +105,7 @@ extension TestCase {
fail(message)
}
}
#endif // ENABLE_MOCKING
func expectNil<T>(
_ actual: T?,
_ message: String? = nil
@@ -142,6 +146,7 @@ extension TestCase {
}
#if ENABLE_MOCKING
internal struct MockTestCase: TestCase {
var file: StaticString
var line: UInt
@@ -241,6 +246,7 @@ internal struct MockTestCase: TestCase {
}
}
}
#endif // ENABLE_MOCKING
internal func withWindowsPaths(enabled: Bool, _ body: () -> ()) {
_withWindowsPaths(enabled: enabled, body)