Skip to content

Commit 520370a

Browse files
authored
Merge branch 'main' into droid
2 parents 95e8fc0 + 3670d67 commit 520370a

File tree

67 files changed

+596
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+596
-339
lines changed
File renamed without changes.

.github/workflows/automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
jobs:
1919
create_merge_pr:
2020
name: Create PR to merge main into release branch
21-
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.3
21+
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.4
2222
with:
2323
head_branch: main
2424
base_branch: release/6.3
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Manual OpenBSD/amd64 build (7.8)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
META_DATA_CONTENT: |
8+
{
9+
"instance-id": "iid-local01",
10+
"dsmode": "local"
11+
}
12+
USER_DATA_CONTENT: |
13+
#cloud-config
14+
timezone: UTC
15+
write_files:
16+
- content: |
17+
set -ex
18+
function atexit {
19+
echo 1 > /tmp/result
20+
tar cvf /dev/sd1c -C /tmp result
21+
halt -p;
22+
}
23+
trap atexit EXIT
24+
printf '\033\143'
25+
export PATH=/usr/local/bin:$PATH
26+
mount /dev/sd3c /mnt
27+
cp -r /mnt/repo /home/repo/
28+
cd /home/repo/
29+
swift test
30+
echo $? > /tmp/result
31+
tar cvf /dev/sd1c -C /tmp result
32+
halt -p
33+
path: /etc/rc.local
34+
permissions: '0755'
35+
36+
jobs:
37+
openbsd:
38+
name: OpenBSD
39+
runs-on: ubuntu-latest
40+
timeout-minutes: 30
41+
container:
42+
image: ghcr.io/3405691582/openbsd-swift-amd64:7.8
43+
env:
44+
CPU: "4"
45+
MEM: "16G"
46+
KVM: "-enable-kvm"
47+
options: --device /dev/kvm
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v5
51+
52+
- name: Write cloud-init files
53+
run: |
54+
echo "$META_DATA_CONTENT" > /usr/local/share/cidata/meta-data
55+
echo "$USER_DATA_CONTENT" > /usr/local/share/cidata/user-data
56+
57+
- name: Prepare cloud-init
58+
run: |
59+
cp -r $GITHUB_WORKSPACE /usr/local/share/cidata/repo/ && \
60+
cat /usr/local/share/cidata/meta-data && \
61+
cat /usr/local/share/cidata/user-data && \
62+
ls /usr/local/share/cidata
63+
64+
- name: Run
65+
run: /usr/local/bin/cmd.sh
66+
67+
- name: Report
68+
run: |
69+
ls -l /usr/local/share/tape && \
70+
exit $(cat /usr/local/share/tape/result)

Documentation/ABI/JSON.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,14 @@ sufficient information to display the event in a human-readable format.
219219
["testID": <test-id>,
220220
["testCase": <test-case>]]
221221
-->
222+
223+
## See Also
224+
225+
### Relevant Swift Evolution proposals
226+
227+
| Proposal Number | Summary | Swift Version | Schema Version |
228+
|:-|-|-:|-:|
229+
| [ST-0002](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0002-json-abi.md) | Introduced the initial version of this JSON schema. | 6.0 | `0` |
230+
| [ST-0009](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0009-attachments.md#integration-with-supporting-tools) | Added attachments. | 6.2 | `0` |
231+
| [ST-0013](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0013-issue-severity-warning.md#event-stream) | Added test issue severity. | 6.3 | `"6.3"` |
232+
| [ST-0016](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0016-test-cancellation.md#integration-with-supporting-tools) | Added test cancellation. | 6.3 | `"6.3"` |

Documentation/Porting.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ to load that information:
193193
```
194194

195195
You will also need to update the `makeTestContentRecordDecl()` function in the
196-
`TestingMacros` target to emit the correct `@_section` attribute for your
196+
`TestingMacros` target to emit the correct `@section` attribute for your
197197
platform. If your platform uses the ELF image format and supports the
198198
`dl_iterate_phdr()` function, add it to the existing `#elseif os(Linux) || ...`
199199
case. Otherwise, add a new case for your platform:
@@ -203,7 +203,7 @@ case. Otherwise, add a new case for your platform:
203203
+++ b/Sources/TestingMacros/Support/TestContentGeneration.swift
204204
// ...
205205
+ #elseif os(Classic)
206-
+ @_section(".rsrc,swft,__swift5_tests")
206+
+ @section(".rsrc,swft,__swift5_tests")
207207
#else
208208
@__testing(warning: "Platform-specific implementation missing: test content section name unavailable")
209209
#endif
@@ -214,6 +214,11 @@ directly into test authors' test targets, so you will not be able to use
214214
compiler conditionals defined in the Swift Testing package (including those that
215215
start with `"SWT_"`).
216216

217+
> [!NOTE]
218+
> We are not using `objectFormat()` yet to maintain compatibility with the Swift
219+
> 6.2 toolchain. We will migrate to `objectFormat()` when we drop Swift 6.2
220+
> toolchain support (presumably after Swift 6.3 ships).
221+
217222
## Runtime test discovery with static linkage
218223

219224
If your platform does not support dynamic linking and loading, you will need to

Package.swift

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ let package = Package(
141141
],
142142
exclude: ["CMakeLists.txt", "Testing.swiftcrossimport"],
143143
cxxSettings: .packageSettings,
144-
swiftSettings: .packageSettings + .enableLibraryEvolution(),
144+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("Testing"),
145145
linkerSettings: [
146146
.linkedLibrary("execinfo", .when(platforms: [.custom("freebsd"), .openbsd]))
147147
]
@@ -189,21 +189,15 @@ let package = Package(
189189
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
190190
],
191191
exclude: ["CMakeLists.txt"],
192-
swiftSettings: .packageSettings + {
193-
var result = [PackageDescription.SwiftSetting]()
194-
192+
swiftSettings: .packageSettings + [
195193
// The only target which needs the ability to import this macro
196194
// implementation target's module is its unit test target. Users of the
197195
// macros this target implements use them via their declarations in the
198196
// Testing module. This target's module is never distributed to users,
199197
// but as an additional guard against accidental misuse, this specifies
200198
// the unit test target as the only allowable client.
201-
if buildingForDevelopment {
202-
result.append(.unsafeFlags(["-Xfrontend", "-allowable-client", "-Xfrontend", "TestingMacrosTests"]))
203-
}
204-
205-
return result
206-
}()
199+
.unsafeFlags(["-Xfrontend", "-allowable-client", "-Xfrontend", "TestingMacrosTests"]),
200+
]
207201
),
208202

209203
// "Support" targets: These targets are not meant to be used directly by
@@ -218,7 +212,7 @@ let package = Package(
218212
dependencies: ["_TestingInternals",],
219213
exclude: ["CMakeLists.txt"],
220214
cxxSettings: .packageSettings,
221-
swiftSettings: .packageSettings + .enableLibraryEvolution()
215+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("_TestDiscovery")
222216
),
223217
.target(
224218
// Build _TestingInterop for debugging/testing purposes only. It is
@@ -228,7 +222,7 @@ let package = Package(
228222
path: "Sources/_TestingInterop",
229223
exclude: ["CMakeLists.txt"],
230224
cxxSettings: .packageSettings,
231-
swiftSettings: .packageSettings
225+
swiftSettings: .packageSettings + .moduleABIName("_TestingInterop")
232226
),
233227

234228
// Cross-import overlays (not supported by Swift Package Manager)
@@ -240,7 +234,7 @@ let package = Package(
240234
],
241235
path: "Sources/Overlays/_Testing_AppKit",
242236
exclude: ["CMakeLists.txt"],
243-
swiftSettings: .packageSettings + .enableLibraryEvolution()
237+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("Testing")
244238
),
245239
.target(
246240
name: "_Testing_CoreGraphics",
@@ -249,7 +243,7 @@ let package = Package(
249243
],
250244
path: "Sources/Overlays/_Testing_CoreGraphics",
251245
exclude: ["CMakeLists.txt"],
252-
swiftSettings: .packageSettings + .enableLibraryEvolution()
246+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("_Testing_CoreGraphics")
253247
),
254248
.target(
255249
name: "_Testing_CoreImage",
@@ -259,7 +253,7 @@ let package = Package(
259253
],
260254
path: "Sources/Overlays/_Testing_CoreImage",
261255
exclude: ["CMakeLists.txt"],
262-
swiftSettings: .packageSettings + .enableLibraryEvolution()
256+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("_Testing_CoreImage")
263257
),
264258
.target(
265259
name: "_Testing_Foundation",
@@ -271,7 +265,7 @@ let package = Package(
271265
// The Foundation module only has Library Evolution enabled on Apple
272266
// platforms, and since this target's module publicly imports Foundation,
273267
// it can only enable Library Evolution itself on those platforms.
274-
swiftSettings: .packageSettings + .enableLibraryEvolution(.whenApple())
268+
swiftSettings: .packageSettings + .enableLibraryEvolution(.whenApple()) + .moduleABIName("_Testing_Foundation")
275269
),
276270
.target(
277271
name: "_Testing_UIKit",
@@ -282,7 +276,7 @@ let package = Package(
282276
],
283277
path: "Sources/Overlays/_Testing_UIKit",
284278
exclude: ["CMakeLists.txt"],
285-
swiftSettings: .packageSettings + .enableLibraryEvolution()
279+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("_Testing_UIKit")
286280
),
287281
.target(
288282
name: "_Testing_WinSDK",
@@ -291,7 +285,7 @@ let package = Package(
291285
],
292286
path: "Sources/Overlays/_Testing_WinSDK",
293287
exclude: ["CMakeLists.txt"],
294-
swiftSettings: .packageSettings + .enableLibraryEvolution()
288+
swiftSettings: .packageSettings + .enableLibraryEvolution() + .moduleABIName("_Testing_WinSDK")
295289
),
296290

297291
// Utility targets: These are utilities intended for use when developing
@@ -369,9 +363,9 @@ extension Array where Element == PackageDescription.SwiftSetting {
369363
static var packageSettings: Self {
370364
var result = availabilityMacroSettings
371365

372-
if buildingForDevelopment {
373-
result.append(.unsafeFlags(["-require-explicit-sendable"]))
374-
}
366+
#if compiler(>=6.3)
367+
result.append(.treatWarning("ExplicitSendable", as: .warning))
368+
#endif
375369

376370
if buildingForEmbedded {
377371
result.append(.enableExperimentalFeature("Embedded"))
@@ -385,10 +379,8 @@ extension Array where Element == PackageDescription.SwiftSetting {
385379

386380
.enableUpcomingFeature("MemberImportVisibility"),
387381

388-
// This setting is enabled in the package, but not in the toolchain build
389-
// (via CMake). Enabling it is dependent on acceptance of the @section
390-
// proposal via Swift Evolution.
391-
.enableExperimentalFeature("SymbolLinkageMarkers"),
382+
// Enabled to allow tests to be added to ~Escapable suites.
383+
.enableExperimentalFeature("Lifetimes"),
392384

393385
.enableUpcomingFeature("InferIsolatedConformances"),
394386

@@ -448,6 +440,30 @@ extension Array where Element == PackageDescription.SwiftSetting {
448440

449441
return result
450442
}
443+
444+
/// Create a Swift setting which specifies the module ABI name to use when
445+
/// building the target with the specified name.
446+
///
447+
/// - Parameters:
448+
/// - targetName The name of the target for which an ABI name should be
449+
/// specified.
450+
///
451+
/// - Returns: A Swift setting that specifies the ABI name of the module of
452+
/// the target named `targetName`.
453+
///
454+
/// This function simplifies the process of specifying a custom module ABI
455+
/// name for various targets in this package. The module ABI name is given a
456+
/// suffix for all targets in this package which emit a module that is also
457+
/// included in the built-in copy of Swift Testing in Swift toolchains and
458+
/// vendor distributions. Without this, there can be runtime collisions; for
459+
/// example, on Darwin platforms (where Swift uses the Objective-C runtime),
460+
/// a non-generic Swift class type causes a warning from the runtime about
461+
/// duplicate class definitions. Specifying a distinct ABI name for each
462+
/// module related to Swift Testing loaded into a runner process avoids this
463+
/// issue.
464+
static func moduleABIName(_ targetName: String) -> Self {
465+
[.unsafeFlags(["-module-abi-name", "\(targetName)_package"])]
466+
}
451467
}
452468

453469
extension Array where Element == PackageDescription.CXXSetting {

Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsImage.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extension NSImageRep {
3636
/// @Metadata {
3737
/// @Available(Swift, introduced: 6.3)
3838
/// }
39+
@available(_uttypesAPI, *)
3940
extension NSImage: AttachableAsImage, AttachableAsCGImage {
4041
/// @Metadata {
4142
/// @Available(Swift, introduced: 6.3)
@@ -58,6 +59,10 @@ extension NSImage: AttachableAsImage, AttachableAsCGImage {
5859
return maxRepWidth ?? 1.0
5960
}
6061

62+
public func withUnsafeBytes<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
63+
try withUnsafeBytesImpl(as: imageFormat, body)
64+
}
65+
6166
public func _copyAttachableValue() -> Self {
6267
// If this image is of an NSImage subclass, we cannot reliably make a deep
6368
// copy of it because we don't know what its `init(data:)` implementation

Sources/Overlays/_Testing_AppKit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
10+
include(ModuleABIName)
1011
add_library(_Testing_AppKit
1112
Attachments/NSImage+AttachableAsImage.swift
1213
ReexportTesting.swift)

Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ extension AttachableAsCGImage {
7474
1.0
7575
}
7676

77-
public func withUnsafeBytes<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
77+
/// The shared implementation of ``AttachableAsImage/withUnsafeBytes(as:_:)``
78+
/// used by types that conform to ``AttachableAsCGImage``.
79+
///
80+
/// For documentation, see ``AttachableAsImage/withUnsafeBytes(as:_:)``.
81+
package func withUnsafeBytesImpl<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
7882
let data = NSMutableData()
7983

8084
// Convert the image to a CGImage.

Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsImage.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ public import CoreGraphics
1414
/// @Metadata {
1515
/// @Available(Swift, introduced: 6.3)
1616
/// }
17+
@available(_uttypesAPI, *)
1718
extension CGImage: AttachableAsImage, AttachableAsCGImage {
1819
/// @Metadata {
1920
/// @Available(Swift, introduced: 6.3)
2021
/// }
2122
package var attachableCGImage: CGImage {
2223
self
2324
}
25+
26+
public func withUnsafeBytes<R>(as imageFormat: AttachableImageFormat, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
27+
try withUnsafeBytesImpl(as: imageFormat, body)
28+
}
2429
}
2530
#endif

0 commit comments

Comments
 (0)