Skip to content

Commit 3bdae3b

Browse files
committed
Merge branch 'main' into jgrynspan/1371-section-used-attributes
2 parents 79498f4 + b559967 commit 3bdae3b

25 files changed

+427
-70
lines changed

Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if SWT_TARGET_OS_APPLE && canImport(CoreGraphics)
1212
public import UniformTypeIdentifiers
1313

14+
/// @Metadata {
15+
/// @Available(Swift, introduced: 6.3)
16+
/// }
1417
@available(_uttypesAPI, *)
1518
extension AttachableImageFormat {
1619
/// The content type corresponding to this image format.

Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ private import CoreGraphics
1313

1414
private import UniformTypeIdentifiers
1515

16+
/// @Metadata {
17+
/// @Available(Swift, introduced: 6.3)
18+
/// }
1619
@available(_uttypesAPI, *)
1720
extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsImage {
1821
/// Get the image format to use when encoding an image, substituting a
@@ -47,11 +50,17 @@ extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: At
4750
return encodingQuality < 1.0 ? .jpeg : .png
4851
}
4952

53+
/// @Metadata {
54+
/// @Available(Swift, introduced: 6.3)
55+
/// }
5056
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
5157
let imageFormat = _imageFormat(forPreferredName: attachment.preferredName)
5258
return try wrappedValue.withUnsafeBytes(as: imageFormat, body)
5359
}
5460

61+
/// @Metadata {
62+
/// @Available(Swift, introduced: 6.3)
63+
/// }
5564
public borrowing func preferredName(for attachment: borrowing Attachment<_AttachableImageWrapper>, basedOn suggestedName: String) -> String {
5665
let imageFormat = _imageFormat(forPreferredName: suggestedName)
5766
return (suggestedName as NSString).appendingPathExtension(for: imageFormat.contentType)

Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ private let _archiverPath: String? = {
121121
return nil
122122
}
123123

124-
return withUnsafeTemporaryAllocation(of: wchar_t.self, capacity: Int(bufferCount)) { buffer -> String? in
124+
return withUnsafeTemporaryAllocation(of: CWideChar.self, capacity: Int(bufferCount)) { buffer -> String? in
125125
let bufferCount = GetSystemDirectoryW(buffer.baseAddress!, UINT(buffer.count))
126126
guard bufferCount > 0 && bufferCount < buffer.count else {
127127
return nil
128128
}
129129

130130
return _archiverName.withCString(encodedAs: UTF16.self) { archiverName -> String? in
131-
var result: UnsafeMutablePointer<wchar_t>?
131+
var result: UnsafeMutablePointer<CWideChar>?
132132

133133
let flags = ULONG(PATHCCH_ALLOW_LONG_PATHS.rawValue)
134134
guard S_OK == PathAllocCombine(buffer.baseAddress!, archiverName, flags, &result) else {

Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if os(Windows)
1212
public import WinSDK
1313

14+
/// @Metadata {
15+
/// @Available(Swift, introduced: 6.3)
16+
/// }
1417
extension AttachableImageFormat {
1518
private static let _encoderPathExtensionsByCLSID = Result {
1619
var result = [CLSID.Wrapper: [String]]()

Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if os(Windows)
1212
private import WinSDK
1313

14+
/// @Metadata {
15+
/// @Available(Swift, introduced: 6.3)
16+
/// }
1417
extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsImage {
1518
/// Get the image format to use when encoding an image.
1619
///
@@ -38,11 +41,17 @@ extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: At
3841
return encodingQuality < 1.0 ? .jpeg : .png
3942
}
4043

44+
/// @Metadata {
45+
/// @Available(Swift, introduced: 6.3)
46+
/// }
4147
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
4248
let imageFormat = _imageFormat(forPreferredName: attachment.preferredName)
4349
return try wrappedValue.withUnsafeBytes(as: imageFormat, body)
4450
}
4551

52+
/// @Metadata {
53+
/// @Available(Swift, introduced: 6.3)
54+
/// }
4655
public borrowing func preferredName(for attachment: borrowing Attachment<_AttachableImageWrapper>, basedOn suggestedName: String) -> String {
4756
let imageFormat = _imageFormat(forPreferredName: suggestedName)
4857
return AttachableImageFormat.appendPathExtension(for: imageFormat.encoderCLSID, to: suggestedName)

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ public struct __CommandLineArguments_v0: Sendable {
210210
/// The value of the `--parallel` or `--no-parallel` argument.
211211
public var parallel: Bool?
212212

213+
/// The maximum number of test tasks to run in parallel.
214+
public var experimentalMaximumParallelizationWidth: Int?
215+
213216
/// The value of the `--symbolicate-backtraces` argument.
214217
public var symbolicateBacktraces: String?
215218

@@ -336,6 +339,7 @@ extension __CommandLineArguments_v0: Codable {
336339
enum CodingKeys: String, CodingKey {
337340
case listTests
338341
case parallel
342+
case experimentalMaximumParallelizationWidth
339343
case symbolicateBacktraces
340344
case verbose
341345
case veryVerbose
@@ -485,6 +489,10 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
485489
if args.contains("--no-parallel") {
486490
result.parallel = false
487491
}
492+
if let maximumParallelizationWidth = args.argumentValue(forLabel: "--experimental-maximum-parallelization-width").flatMap(Int.init) {
493+
// TODO: decide if we want to repurpose --num-workers for this use case?
494+
result.experimentalMaximumParallelizationWidth = maximumParallelizationWidth
495+
}
488496

489497
// Whether or not to symbolicate backtraces in the event stream.
490498
if let symbolicateBacktraces = args.argumentValue(forLabel: "--symbolicate-backtraces") {
@@ -545,7 +553,22 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
545553
var configuration = Configuration()
546554

547555
// Parallelization (on by default)
548-
configuration.isParallelizationEnabled = args.parallel ?? true
556+
if let parallel = args.parallel, !parallel {
557+
configuration.isParallelizationEnabled = parallel
558+
} else {
559+
var maximumParallelizationWidth = args.experimentalMaximumParallelizationWidth
560+
if maximumParallelizationWidth == nil && Test.current == nil {
561+
// Don't check the environment variable when a current test is set (which
562+
// presumably means we're running our own unit tests).
563+
maximumParallelizationWidth = Environment.variable(named: "SWT_EXPERIMENTAL_MAXIMUM_PARALLELIZATION_WIDTH").flatMap(Int.init)
564+
}
565+
if let maximumParallelizationWidth {
566+
if maximumParallelizationWidth < 1 {
567+
throw _EntryPointError.invalidArgument("--experimental-maximum-parallelization-width", value: String(describing: maximumParallelizationWidth))
568+
}
569+
configuration.maximumParallelizationWidth = maximumParallelizationWidth
570+
}
571+
}
549572

550573
// Whether or not to symbolicate backtraces in the event stream.
551574
if let symbolicateBacktraces = args.symbolicateBacktraces {

Sources/Testing/Attachments/Images/AttachableAsImage.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public protocol AttachableAsImage {
8181
/// The testing library uses this function when saving an image as an
8282
/// attachment. The implementation should use `imageFormat` to determine what
8383
/// encoder to use.
84+
///
85+
/// @Metadata {
86+
/// @Available(Swift, introduced: 6.3)
87+
/// }
8488
borrowing func withUnsafeBytes<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R
8589

8690
/// Make a copy of this instance to pass to an attachment.

Sources/Testing/Attachments/Images/AttachableImageFormat.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public struct AttachableImageFormat: Sendable {
7979

8080
// MARK: - Equatable, Hashable
8181

82+
/// @Metadata {
83+
/// @Available(Swift, introduced: 6.3)
84+
/// }
8285
#if SWT_NO_IMAGE_ATTACHMENTS
8386
@_unavailableInEmbedded
8487
@available(*, unavailable, message: "Image attachments are not available on this platform.")
@@ -120,12 +123,18 @@ extension AttachableImageFormat.Kind: Equatable, Hashable {
120123

121124
// MARK: - CustomStringConvertible, CustomDebugStringConvertible
122125

126+
/// @Metadata {
127+
/// @Available(Swift, introduced: 6.3)
128+
/// }
123129
#if SWT_NO_IMAGE_ATTACHMENTS
124130
@_unavailableInEmbedded
125131
@available(*, unavailable, message: "Image attachments are not available on this platform.")
126132
#endif
127133
@available(_uttypesAPI, *)
128134
extension AttachableImageFormat: CustomStringConvertible, CustomDebugStringConvertible {
135+
/// @Metadata {
136+
/// @Available(Swift, introduced: 6.3)
137+
/// }
129138
public var description: String {
130139
let kindDescription = String(describing: kind)
131140
if encodingQuality < 1.0 {
@@ -134,6 +143,9 @@ extension AttachableImageFormat: CustomStringConvertible, CustomDebugStringConve
134143
return kindDescription
135144
}
136145

146+
/// @Metadata {
147+
/// @Available(Swift, introduced: 6.3)
148+
/// }
137149
public var debugDescription: String {
138150
let kindDescription = String(reflecting: kind)
139151
return "\(kindDescription) at quality \(encodingQuality)"
@@ -142,6 +154,9 @@ extension AttachableImageFormat: CustomStringConvertible, CustomDebugStringConve
142154

143155
// MARK: -
144156

157+
/// @Metadata {
158+
/// @Available(Swift, introduced: 6.3)
159+
/// }
145160
#if SWT_NO_IMAGE_ATTACHMENTS
146161
@_unavailableInEmbedded
147162
@available(*, unavailable, message: "Image attachments are not available on this platform.")

Sources/Testing/Attachments/Images/Attachment+AttachableAsImage.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11+
/// @Metadata {
12+
/// @Available(Swift, introduced: 6.3)
13+
/// }
1114
#if SWT_NO_IMAGE_ATTACHMENTS
1215
@_unavailableInEmbedded
1316
@available(*, unavailable, message: "Image attachments are not available on this platform.")

Sources/Testing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ add_library(Testing
9090
Support/Graph.swift
9191
Support/JSON.swift
9292
Support/Locked.swift
93+
Support/Serializer.swift
9394
Support/VersionNumber.swift
9495
Support/Versions.swift
9596
Discovery+Macro.swift

0 commit comments

Comments
 (0)